Skip to content
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

Indicate when referenced schema isn't available #71

Open
chrahunt opened this issue May 16, 2015 · 1 comment
Open

Indicate when referenced schema isn't available #71

chrahunt opened this issue May 16, 2015 · 1 comment

Comments

@chrahunt
Copy link
Collaborator

If a schema is being referenced via $ref and that reference cannot be resolved within the schema itself or from one of the schemas passed into the schemas property of the options, this needs to be indicated. A reasonable default would be to throw an error, but it would also be appropriate to indicate this issue at validation-time (as done in #46).

This would help take care of some of the issues referenced in #22.

@chrahunt chrahunt changed the title Throw error when referenced schema isn't available Indicate when referenced schema isn't available May 16, 2015
@chrahunt
Copy link
Collaborator Author

A review of other JSON-Schema validators shows a pretty even split between the two possible ways of handling this:

  1. throwing an error on compilation which is separate from the normal schema error-handling, or
  2. reporting unresolved references in the same way as validation errors
Name Error Time1 External Schema inclusion2
JJV on validation registration3
JSEN on compilation N/A
jsck on compilation both
Z-Schema on validation registration
tv4 on validation registration
imjv N/A all-at-once4

It seems like the compilation-time error-throwing is present on the validation libraries that are closer in interface to this library, so it could be the least-surprising solution. Additionally, since the main schema and all possible remotes are given at the same time, we don't need to worry about the possibility of a referenced schema being supplied later.

1 at what point unresolved reference errors are indicated
2 interface used to add remote schema references
3 interface that allows 'registering' remote schemas using a method, e.g. in Z-Schema: validator.setRemoteReference(requiredUrl, JSON.parse(body));
4 interface like in imjv, where remote schemas are provided at the same time as the main schema to validate against

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant