-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect swagger.json generation when using FromForm parameters without the WithOpenApi extension method #52284
Comments
I just stumbled upon this problem as well. Good thing you made this issue or I probably wouldn't have found a (bandaid) fix like you did - as it involves a package I didn't realize existed. |
The schema generation for each of these components is controlled by |
Is there any discussion into creating a first party definition generator for AspNetCore? It doesn't need a full blown swagger UI and all that jazz, but just the json file would be lovely! Swashbuckle hasn't had an update in almost a year, and NSwag currently doesn't support forms in Minimal APIs at all. It feels weird how there's so much effort spent making the OpenAPI package and the API explorer and whatnot but seemingly in order to use it for anything useful you need a third party package (or write a lot of code yourself). ... Unless I've missed something and there is a built-in schema generator that I've managed to dodge through my web searches. |
Hopefully more on this front soon. 😅 I've done some prototyping on this in a sample branch but it needs considerable work before it can formalized. Feedback that supporting just the OpenAPI document generation into a JSON file is great to share! I've always been of the opinion that an artifact that you can integrate with other systems (client generation, Postman, API management, etc.) is the most important aspect of this work. |
I've verified that our built-in document generation is doing the right thing here and added some test coverage in #55321. In the future, I plan on replating Closing this as resolved with a fix incoming in preview4. |
Update: we ended up not pursuing this plan for In any case, the underlying issue is resolved in the built-in implementation. If there are still issues with Swashbuckle.AspNetCore, we should trakc them over there. |
For completeness sake; you went with option 1, right? |
Correct. I added a remark to the API that it's only compatible with Swashbuckle.AspNetCore. aspnetcore/src/OpenApi/src/Extensions/OpenApiEndpointConventionBuilderExtensions.cs Lines 27 to 30 in 0e4ccd1
NSwag hasn't added support for |
Is there an existing issue for this?
Describe the bug
I have the following endpoints:
These endpoints differ only for the
WithOpenApi
extension method, but theswagger.json
definition is quite different:So, in Swagger I get the following result:
WRONG
CORRECT
Expected Behavior
Both the endpoints should produce the same
swagger.json
definition that defines the parameters fromForm
.Steps To Reproduce
Minimal repro here: https://github.com/marcominerva/FromFormIssue
Exceptions (if any)
No response
.NET Version
8.0.100
Anything else?
No response
The text was updated successfully, but these errors were encountered: