Fail if schema used for validation has missing references #1116
Unanswered
lblatchford
asked this question in
Q&A
Replies: 1 comment 3 replies
-
It should already be throwing an exception if references cannot be resolved by default. I'm also not sure why you are mentioning the standard meta schema files as the standard meta schema files are bundled with the library. This library isn't a linter. Typically the best you can do with this library is use the meta schema to validate a schema and attempt to load it to resolve references. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi - I'm need to be able to validated customer-provided JSON instances against customer-provided JSON schemas. I have this validation working with the following code:
I'd like to prevent validation from being performed for invalid schemas - specifically, I want to be sure that all references are defined. I haven't figured out a way to accomplish this consistently. I found a scenario in which InvalidSchemaRefException was thrown if I tried validation against an instance doc of "{}", but this did not work for all schemas with missing references I tried.
For example, the 2020-12 draft schema consists of several files: schema, meta/applicator, meta/content, meta/core, meta/format-annotation, meta/meta-data, meta/unevaluated and meta/validation.
If I have the 'schema' file present but the meta directory is not, the validation code above still passes. This is another case of missing references I'd like to catch (though generally this would be with customer schemas versus the draft schema). I'm guessing validation passed since I have the V202012 metaschema used by default?
How can undefined references be identified whether from missing files or missing definitions in a single schema file?
Suggestions greatly appreciated
Beta Was this translation helpful? Give feedback.
All reactions