-
Notifications
You must be signed in to change notification settings - Fork 10.3k
OpenAPI Ref invalid when objects cycles #58915
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
Use JsonIgnore for Circular Property |
This is Microsoft.Openapi and the reference in schema are not RFC3986 compliant. To use AddSwaggerGen from swashbuckle is a workaround, but not a fix on the bug |
It doesn't even have to cycle. It's enough to reference the same class twice in two different collections. public class WeatherForecast
{
// Having "Update" in two lists causes the bug to surface.
public List<Update> RainUpdates { get; set; }
public List<Update> HurricaneUpdates { get; set; }
}
public sealed class Update
{
public DateOnly Date { get; set; }
public string Message { get; set; }
} |
Hitting same issue without cycles. Likely related to #58968. |
I could reproduce this with another example (see Gist) public class OrderResponse
{
public string Id { get; set; }
public decimal Amount { get; set; }
public List<Transaction>? Transactions { get; set; }
public List<Item> Items { get; set; }
}
public class Transaction
{
public string Id { get; set; }
public List<Item> Items { get; set; }
}
public class Item
{
public string Id { get; set; }
} The swagger editor complains about the following:
It does not play nicely with collections of the same type |
I'm hitting this issue with a non-cycling class. Just two types having a property of type SomeType[]. The references in the "items" property of the OpenAPI document are messed up. Hope there will be a for .net 9. |
I am also have the same issue - the generated json files are not usable. Is there any idea on when a fix will be available or a possible workaround? |
Closing this in favor of #58968. I believe it's the same issue. Latest update on this over at #58968 (comment). |
Still invalid ref in 9.0.2 |
Is there an existing issue for this?
Describe the bug
If you have an model with types as following Person->Address->Person
The referens get invalid and doesnt point to a type in components
"$ref": "#/components/schemas/#/properties/myAddress/properties/mailOfficer"
Expected Behavior
$refs must reference a valid location in the document
Steps To Reproduce
Example application
Schema output
Exceptions (if any)
No response
.NET Version
9.0.100
Anything else?
No response
The text was updated successfully, but these errors were encountered: