-
Notifications
You must be signed in to change notification settings - Fork 356
How to validate against json schema containing circular $ref? #274
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
For an example of |
@csimplestring The schema can have circular dependencies which are resolved by the RefResolver. It will create an object graph in the memory. This schema in memory can be used to validate your data against. So this library can handle all $ref cases. |
Can you give me an example code? Thanks! ---Sent from Boxer | http://getboxer.com On 28 May 2016 09:56:56 CEST, Joost Nijhuis notifications@github.com wrote:@csimplestring The schema can have circular dependencies which are resolved by the RefResolver. It will create an object graph in the memory. This schema in memory can be used to validate your data against. So this library can handle all $ref cases. —You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread. |
@jojo1981 Thanks for your work. I just try it by using it. When I want to validate against a circular reference json schema, it seems to fail due to infinite recursion loop and use up all memory. Do I use the RefResolver in a wrong way? I just use the RefResolver as the example in readme, also I notice there is a big change in API. So I guess maybe it is better to give me a demonstration or example in a correct way? |
Yes, RefResolver inlines all refs, so you get an infinite loop if you have recursion in your schema |
It's necessary to rethink schema compilation to avoid this problem |
@csimplestring and @psafarov The RefResolver should be able to handle this. Can you verify you're using the newest version of this library? Also can you add the schema you're using? Then I can try to reproduce this. |
@jojo1981 unfortunately, I cant publish the schema I used, but what I found is that it occurs because object with reference to itself inside gets to ObjectIterator which iterates object recursively |
#277 the issue is solved in this pull request |
Hi, @jojo1981 Sorry for late response. After checking with my colleages, we found that the RefResovler should not be re-used in a for-loop. In our code, we want to cache all the resolved schemas, so we write like this:
I guess the RefResolver maintains a cache internally, could you explain a bit? |
Circular references came in #277 and are available in 3.0.0 |
Hi, thanks for this great work. I found that there is a new major version released to support $ref. However, where can I find the usage example about it?
Now I have json schema files, which some of them contains circular $ref. Namely, schema-A.json has a $ref to schema-B.json, schema-B.json has a $ref to schema-A.json.
Any help is appreciated and thanks in advanced.
The text was updated successfully, but these errors were encountered: