-
Notifications
You must be signed in to change notification settings - Fork 331
Schema id does not declare a base URL for relative $ref URLs #26
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
i was this issue too.. |
created PR it could be better, if we can had some level of cache for the url/content, it would not be necessary to be downloading the content to each $ref as it always made "new RefValidator" |
@eskabetxe I think it is cached as we only parse schema in the factory once. And all the validators are created during parsing and cached in a map. I didn't look at the code but make the comment based on the way it was implemented. If you could confirm that we parse the ref on a per request basis, then we definitely need to get it fixed. Could you please confirm? Thanks. |
for this example the $ref file (rules.json) will be charge 3 times.. i think that prop1, prop2, etc are cached, but the file rules.json is download 3 times and this could be improved |
This issue should be resolved by #141 |
When resolving relative
$ref
erences, URLs are constructed using the reference value directly without using the base URL of the referencing schema.https://spacetelescope.github.io/understanding-json-schema/structuring.html?highlight=dependencies#the-id-property
For example, if you own the
foo.bar
domain, and you had a schema for addresses, you may set its id as follows:"id": "http://foo.bar/schemas/address.json"
This provides a unique identifier for the schema, as well as, in most cases, indicating where it may be downloaded. For example:
{ "$ref": "person.json" }
A JSON schema validation library would fetch
person.json
fromhttp://foo.bar/schemas/person.json
, even ifaddress.json
was loaded from the local filesystem.The text was updated successfully, but these errors were encountered: