-
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
OpenAPI document generation does not generate correct refs for self-referencing collection properties #58006
Comments
@null-d3v Thanks for reporting this issue! I'm hoping to drop a fix for this in the upcoming .NET 9 GA release. Once the change is merged, you can try out the fix in one of our nightly releases of the package. If you're interested in learning how to do that, let me know and I can share instructions. |
@captainsafia Thanks for the prompt reply!! I haven't had to pull from the nightly feed yet, but I've worked out the setup. Very enthused about this in .NET 9! We have a lot of document generation with NSwag that we're anticipating to change. |
* Fix JsonUnmappedMemberHandling attribute handling to close #57981 * Fix enum handling for MVC actions to close #57979 * Fix self-referential schema handling to close #58006 * Fix concurrent request handling for OpenAPI documents (#57972) * fix: Allow concurrent requests * test: Update test * test: Use Parallel.ForEachAsync * feat: Use valueFactory overload * feat: Pass valueFactory directly * Harden self-referencing schema ID check --------- Co-authored-by: Justin Lampe <xC0dex@users.noreply.github.com>
* Fix JsonUnmappedMemberHandling attribute handling to close #57981 * Fix enum handling for MVC actions to close #57979 * Fix self-referential schema handling to close #58006 * Fix concurrent request handling for OpenAPI documents (#57972) * fix: Allow concurrent requests * test: Update test * test: Use Parallel.ForEachAsync * feat: Use valueFactory overload * feat: Pass valueFactory directly * Harden self-referencing schema ID check --------- Co-authored-by: Justin Lampe <xC0dex@users.noreply.github.com>
@null-d3v The fix for this has landed in nightly package version You'll need to use the following
And make sure that you have a reference to the nightly dotnet9 feed in your
Can you verify the fix on your end? |
Sorry for the late reply, this is definitely fixed in |
… (#58096) * Fix JsonUnmappedMemberHandling attribute handling to close #57981 * Fix enum handling for MVC actions to close #57979 * Fix self-referential schema handling to close #58006 * Fix concurrent request handling for OpenAPI documents (#57972) * fix: Allow concurrent requests * test: Update test * test: Use Parallel.ForEachAsync * feat: Use valueFactory overload * feat: Pass valueFactory directly * Harden self-referencing schema ID check --------- Co-authored-by: Justin Lampe <xC0dex@users.noreply.github.com>
Is there an existing issue for this?
Describe the bug
Microsoft.AspNetCore.OpenApi
will generate an invalid JSON schema when a parameter has a self-reference collection property. This does not seem to occur if the self reference is not a collection.Using the following as a parameter:
Will result in the JSON schema:
Which has an invalid reference:
This occurs with both minimal APIs and controllers.
Expected Behavior
I would expect the
subCriteria
items
reference to correctly point at#/components/schemas/Criteria
.Steps To Reproduce
Here is a complete self-contained
Program.cs
which will generate the invalid OpenAPI document:And the OpenAPI document generated at
/openapi/v1.json
:Exceptions (if any)
No response
.NET Version
9.0.100-rc.1.24452.12
Anything else?
No response
The text was updated successfully, but these errors were encountered: