-
Notifications
You must be signed in to change notification settings - Fork 10
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
Infinite recursion when "$ref" at root. #92
Comments
I also tried just pointing directly to the definition I wanted to generate instead of relying on the "$ref" at the root: But I got an error:
|
A root-level
The |
Just to give some context: Statham is the first JSONSchema tool I've encountered that doesn't handle a root Things that supported it:
The main advantage that I see is that the root type gets a name, instead of relying on its file name to name it. Plus all your schemas are defined in the same "definitions" block instead of having them in two different places. 🤷 |
Also, I only figured that out after some testing on my part. I very nearly abandoned investigating statham earlier and just assumed the tool was broken. If you don't want to support root "$ref", it might be a good idea to check for root "$ref" and give an error that it's not supported. My initial perception was that statham might've been broken/unmaintained. Sorry for being verbose. I also maintain some OSS projects and I prefer users report issues rather than not. Trying to return the favor. Thanks for making this tool available! 👍 |
Describe the bug
When the root type of a schema is a
$ref
, statham has infinite recursion.Steps to Reproduce
Working schema:
Schema that breaks statham:
Expected behaviour
I expect both above schemas to output identical/similar models.
Actual behaviour
stack overflow:
System information
pip freeze
)Workaround
I guess I won't use a "$ref" at my root.
Though the schema generator I'm using (https://github.com/StefanTerdell/zod-to-json-schema) does this by default.
The text was updated successfully, but these errors were encountered: