-
Notifications
You must be signed in to change notification settings - Fork 10.3k
WithOpenApi adds Empty requestBody when parameter is of type string[] or StringValues #47644
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
Comments
@cleftheris Thanks for the bug report! I tracked it down to this line of code: Fix incoming... |
Wow thanks @captainsafia you are very quick! Can we expect this to land on dotnet7.0 as a hot fix or I have to wait for dotnet8? I got a couple more issues to report on OpenAPI since we migrated a large code base to minimal APIs and have had the time to check things out. Thanks again for your work |
@captainsafia thank you for your really quick fix. Do you believe this fix can be included in a minor or patch release of the Microsoft.AspNetCore.OpenApi package? A stable .NET 8 probably needs a significant amount of time to be released and it may be source incompatible or have breaking changes with our existing code base. So we will need some time to adopt it! |
Don't hesitate to report issues here! I look forward to polishing up this area.
We can push a hotfix for this. I'll re-open the issue to track backporting to the next servicing release for 7.0. |
@captainsafia that sound perfect. Thanks again for your immediate action! |
PR to backport to .NET 7: #47807 |
Closing since backport has been merged. |
Is there an existing issue for this?
Describe the bug
When mapping any operation that has no actual body and one of the method argumets is of type
string[]?
orStringValues
according to the documentation the api should infer that to be from query string unless explicitly configured otherwise.Although this actually works fine for calling the endpoint, when generating documentation an empty body appears.
This happens by simply using the
WithOpenApi
extension method. When I debug I find that the operation.RequestBody parameter is populated (should be null if you check with other operations).The operation
The generated swagger json
Link to the documentation
Expected Behavior
There should not be a requestBody at all there.
Steps To Reproduce
I have prepared a project here https://github.com/cleftheris/WithOpenApiBug
It is just the default aspnet 7 template with the below code added to the Project.cs
Exceptions (if any)
No response
.NET Version
7.0.4
Anything else?
.NET SDK:
Version: 7.0.202
Commit: 6c74320bc3
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.202\
Host:

Version: 7.0.4
Architecture: x64
Commit: 0a396acafe
The text was updated successfully, but these errors were encountered: