-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Incorrect OpenAPI document generation with recursive object that contains a list #60012
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
I found out that if you invert the position of the two properties, putting the "Tags" first and then "Parent", it all works as expected "components": {
"schemas": {
"Category": {
"required": [
"name"
],
"type": "object",
"properties": {
"name": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Tag"
}
},
"parent": {
"$ref": "#/components/schemas/Category"
}
}
},
"Tag": {
"required": [
"name"
],
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
}
}
},
"tags": [
{
"name": "RecursiveObjectIssue"
}
] |
This looks like it might be a dup of #59976 |
The issue still happens with .NET 9.0.2 |
Thanks for filing this issue, @marcominerva! You've already dupped it to #60381 where I've left a comment but figured I'd make a reference to that comment here. Similar to the above, I've included a test for this in the branch associated with the backport. For now, closing this one as a dupe of the referenced issue. |
Is there an existing issue for this?
Describe the bug
In a .NET 9.0.1 Minimal API project with Microsoft.AspNetCore.OpenApi, I have the following endpoint, returning a recursive object that also contains a list:
With this code, the OpenAPI definition is wrong:
If I remove the
Parent
property fromCategory
, the document is correctly generated:Note that the issue happens even when using a primitive type for the collection (for example
string
).Expected Behavior
No response
Steps To Reproduce
Minimal repro at https://github.com/marcominerva/RecursiveObjectIssue.
Exceptions (if any)
No response
.NET Version
9.0.102
Anything else?
No response
The text was updated successfully, but these errors were encountered: