Comments (8)
public class RouterCreationSuccess
{
[JsonProperty("crmSuccess")] public bool CrmSuccess { get; set; }
[JsonProperty("iotSuccess")] public bool IotSuccess { get; set; }
}
public class Response<T>
{
public Response()
{
ErrorCodes = new List<Error>();
DebugMessage = "";
Result = new Result<T>();
}
[JsonProperty("result")] public Result<T> Result { get; set; }
[JsonProperty("debugMessage")] public string DebugMessage { get; set; }
[JsonProperty("errorCodes")] public List<Error> ErrorCodes { get; set; }
}
public class Result<T>
{
[JsonProperty("value")] public T Value { get; set; }
}
public class Error
{
[JsonProperty("message")] public string Message;
[JsonProperty("error")] public string Type { get; set; }
}
public class Router{}
public class Bug
{
[FunctionName(FunctionNames.AddRouter)]
[OpenApiOperation(operationId: nameof(AddRouter), tags: new[] { "router" }, Summary = "Adds a router", Description = "Registers a new router in the system", Visibility = OpenApiVisibilityType.Important)]
[OpenApiRequestBody("application/json", typeof(Router), Required = true)]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Response<RouterCreationSuccess>), Summary = "The response", Description = "This returns the response")]
[OpenApiResponseWithoutBody(statusCode: HttpStatusCode.MethodNotAllowed, Summary = "Invalid input", Description = "Invalid input")]
public async Task<IActionResult> AddRouter(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "router")]
HttpRequest req,
[FromBody] Router newRouter,
ILogger log)
{
return null;
}
[FunctionName("FunctionNames.AddRouter2")]
[OpenApiOperation(operationId: nameof(AddRouter2), tags: new[] { "router" }, Summary = "Adds a router", Description = "Registers a new router in the system", Visibility = OpenApiVisibilityType.Important)]
[OpenApiRequestBody("application/json", typeof(Router), Required = true)]
[OpenApiResponseWithBody(statusCode: HttpStatusCode.OK, contentType: "application/json", bodyType: typeof(Response<int>), Summary = "The response", Description = "This returns the response")]
[OpenApiResponseWithoutBody(statusCode: HttpStatusCode.MethodNotAllowed, Summary = "Invalid input", Description = "Invalid input")]
public async Task<IActionResult> AddRouter2(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "router")]
HttpRequest req,
[FromBody] Router newRouter,
ILogger log)
{
return null;
}
}
from azure-functions-openapi-extension.
this is the error i get if both use Response<T>
:
[2021-03-10T01:15:20.522Z] Executed 'RenderSwaggerDocument' (Failed, Id=a442e2f7-a52c-4ccd-90d5-ea434e996a74, Duration=91ms)
[2021-03-10T01:15:20.524Z] System.Private.CoreLib: Exception while executing function: RenderSwaggerDocument. System.Private.CoreLib: An item with the same key has already been added. Key: response.
and if i change Response<int>
to just int
, then no error but the Response<RouterCreationSuccess>
doesn't show correctly in models section
from azure-functions-openapi-extension.
thanks @justinyoo . I've already changed my object structure since i was under a timeline crunch, but if it works for the sample, then i'll eventually migrate back to my old setup. Thanks for the fix!
from azure-functions-openapi-extension.
Hello, with a generic type it's working now.
Here I am having a problem when there are two generic types.
it works:
Response<T>
It does not work:
Response<IEnumerable<T>>
from azure-functions-openapi-extension.
@powerdude Thanks for the issue. To repro on my side, could you provide more details how you got into that, including your class definitions?
from azure-functions-openapi-extension.
Same problem here when using OpenApiResponseWithBody
with a generic type MyGenericClass<Data>
from azure-functions-openapi-extension.
@justinyoo I can pick this up if you give me some guidance on what the correct result should be. The call that is failing is Line 253 here because GetOpenApiTypeName
is returning the generic root. If two methods have two responses with the same generic root and different type params the dictionary tries to add twice with the same key.
Based on what I am seeing in the samples, the convention being used for generics is to append a _
to the generic type with the generic type param.
Edit: Repro is here: https://github.com/ssa3512/azure-functions-openapi-extension/commit/d889f35c9c16fa9f7eb5b7021f96a59647254962
from azure-functions-openapi-extension.
@powerdude It's been released to NuGet. Please have a look and let us know.
from azure-functions-openapi-extension.
Related Issues (20)
- Microsoft.Azure.Functions.Worker.Extensions.OpenApi throws System.IO.FileNotFoundException HOT 2
- Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore support HOT 1
- .NET 8, Function Decorators Not Recognized HOT 27
- Loading types from referenced dll's should be optional, very poor performance of generating swagger document for large projects.
- .NET 8 isolated process - "The type or namespace name 'Azure' does not exist..." HOT 1
- Cannot Generate Open API swagger.json file if inheriting from ITableEntity From Azure.Data.Tables HOT 1
- Support for X-Forwarded-Host HOT 2
- Ordering tags alphanumerically
- IOpenApiHttpTriggerAuthorization requires IHttpRequestDataObject but function has HttpRequestData
- Support Specification Extensions HOT 1
- Setting the base url in isolated worker azure function HOT 2
- Add more options to control exposed Swagger endpoints HOT 1
- .NET framework Isolated - The system cannot find the file specified.
- No way to add example to a parameter definition using attributes - OpenApiParameterAttribute does not support all properties of Microsoft.OpenApi.Models OpenApiParameter
- Easy Auth enabled on Azure portal for function app not allowed to exposed Swagger endpoints
- Future of this project? HOT 3
- Adding custom attribute to the openAPI endpoints possible?
- Documentation: Update .ConfigureFunctionsWorkerDefaults(...) to be .ConfigureFunctionsWebApplication(...)
- Synchronous operations are disallowed HOT 1
- Generate OpenApi swagger at build time. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-functions-openapi-extension.