Closed cmenzi closed 7 months ago
Same error with a simple Post Route :
var api = app.MapGroup("api");
api.MapPost("/{user}/{entityName}", ( string user, string entityName, Entity entity) => { /*my code*/ })
.WithOpenApi();
An unhandled exception has occurred while executing the request.
System.InvalidOperationException: The operation 'PostApi' has more than one body parameter.
at NSwag.Generation.AspNetCore.Processors.OperationParameterProcessor.EnsureSingleBodyParameter(OpenApiOperationDescription operationDescription)
at NSwag.Generation.AspNetCore.Processors.OperationParameterProcessor.Process(OperationProcessorContext operationProcessorContext)
at NSwag.Generation.AspNetCore.AspNetCoreOpenApiDocumentGenerator.RunOperationProcessors(OpenApiDocument document, ApiDescription apiDescription, Type controllerType, MethodInfo methodInfo, OpenApiOperationDescription operationDescription, List`1 allOperations, OpenApiDocumentGenerator generator, OpenApiSchemaResolver schemaResolver)
at NSwag.Generation.AspNetCore.AspNetCoreOpenApiDocumentGenerator.AddOperationDescriptionsToDocument(OpenApiDocument document, Type controllerType, List`1 operations, OpenApiDocumentGenerator swaggerGenerator, OpenApiSchemaResolver schemaResolver)
at NSwag.Generation.AspNetCore.AspNetCoreOpenApiDocumentGenerator.GenerateApiGroups(OpenApiDocumentGenerator generator, OpenApiDocument document, IGrouping`2[] apiGroups, OpenApiSchemaResolver schemaResolver)
at NSwag.Generation.AspNetCore.AspNetCoreOpenApiDocumentGenerator.GenerateAsync(ApiDescriptionGroupCollection apiDescriptionGroups)
at NSwag.AspNetCore.Middlewares.OpenApiDocumentMiddleware.GenerateDocumentAsync(HttpContext context)
at NSwag.AspNetCore.Middlewares.OpenApiDocumentMiddleware.GetDocumentAsync(HttpContext context)
at NSwag.AspNetCore.Middlewares.OpenApiDocumentMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
I tried to add FromRoute / FromBody decorators on parameters, but error still occurs
Same issue when trying to migrate from Swashbuckle to NSwag with the below code:
app.MapPost("/test", async (CreateTestRequest request, [FromServices] ISender sender) =>
{
// Code Here
}
.WithName("CreateTest")
.Produces<CreateTestResponse>(StatusCodes.Status201Created)
.ProducesProblem(StatusCodes.Status201Created)
.WithOpenApi();
I hit the same problem across multiple methods ... appears fundamentally broken and needs to be pulled!
Should be fixed in v14.0.5, please open issue if problem persists.
Just pulled 14.0.5 and it is resolved for me, thanks.
That fixed it, thank you.
That fixed it for me too, thanks ;)
Fixed for me as well. @RicoSuter Thx
Hi Rico
Since version 14.0.4 I'm not able to generate my openapi.json anymore with the following exception.
Everything worked in 14.0.3.
It somehow detects multiple body parameters in all my POST and PUT operations, like The operation 'CreateUser' has more than one body parameter.
This is how my MapPost looks like:
As you can see, there is only one DTO
CreateUserCommand
in the delegate.Any ideas?