-
-
Notifications
You must be signed in to change notification settings - Fork 591
Better documentation on extending RefResolver #225
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
Hey! This is a duplicate of #135, but yes you're certainly right, documentation would be great here, would be awesome if you could write up what you've found possibly? For your specific solution, Thanks! |
Thanks for the quick reply, sorry I didn't see #135 previously. I'll have a read through and leave my thoughts, thanks again :) |
I was able to find an alternative way to support this on #!/usr/bin/env python
import jsonschema
import json
rootschema = json.load("""
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"link": {
"type": "number"
}
}
}
""")
schema = json.load("""
{
"type": "object",
"properties": {
"field": { "$ref": "/v1/rootschema.json#/definitions/link" }
}
}
""")
doc = json.load("""
{
"field": 0
}
""")
validator_cls = jsonschema.validators.validator_for(schema)
validator_cls.check_schema(schema)
validator = validator_cls(schema)
validator.resolver.store['/v1/rootschema.json'] = rootschema
validator.validate(doc) |
@foxx Were you able to find a solution using |
The documentation made it quite difficult to understand how
RefResolver
should be extended, and I had to trawl through code to make it work. This is useful when you want to reference other schemas, but you don't want to usefile://
It would be nice to see better documentation on this, but in the mean time, here is how I got it working for anyone who runs into the same problem;
The text was updated successfully, but these errors were encountered: