-
Notifications
You must be signed in to change notification settings - Fork 21
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
Response validation panic when body uses array circular reference field #103
Comments
Hmm... this is a bug, the schema should bundled inline so there is no ref. |
Actually. This is not a bug. Well kinda. but not..
It cannot be rendered, so when it's passed to the validator, it remains as is.. {
"properties" : {
"code" : {
"type" : "string"
},
"details" : {
"items" : {
"$ref" : "#/components/schemas/Error"
},
"type" : "array"
}
},
"type" : "object"
} This is what the validator gets. which is why it's failing. The fix here is to either fail gracefully, warning of the circular reference.. or, determine it's a circular reference and then extract those circular references and add them to the schema validator one by one as resources, but this is a huge amount of work. |
Sorry, pressed return too quickly. |
If you consider it non-critical, I could try to do that work myself. The original problem has been sidestepped in production, so I could just try to improve this for its own sake. PR allowed? |
All PRs are most welcome. I only have some many hours in the week to work on new stuff or upgrade existing stuff - so your contribution would be most welcome. |
I consistently get a panic in a production use case. Here is a minimal reproduction:
This results in:
Considering that this library does not consider (non-required) circular references errors, and both building a model and validating it pass, I am wondering if this is just a bug or I am missing something.
Tracking down the error, I got to
libopenapi-validator/responses/validate_response.go
Lines 131 to 132 in 7b4e021
Some error validation would be useful, don't know at the moment how to solve
The text was updated successfully, but these errors were encountered: