-
Notifications
You must be signed in to change notification settings - Fork 8
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
Replace definitions
with $defs
in JSON Schema artifact
#109
base: main
Are you sure you want to change the base?
Conversation
2a75825
to
bde8ace
Compare
tests/test_validate_artifacts.py
Outdated
assert_that(json_schema).is_not_empty() | ||
|
||
# Idea from https://github.com/Julian/jsonschema/issues/348#issuecomment-647418176 | ||
class SaferDraft202012Validator(jsonschema.Draft202012Validator): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gaurav: is there any specific reason why we want to use this SaferDraft202012Validator
class rather than just Draft202012Validator
or Draft7Validator
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not Draft7Validator
: because it uses definitions
rather than $defs
, which is what we're trying to move to.
Why not Draft202012Validator
: because by default Draft202012Validator
sets additionalProperties
to true, which makes the validator very permissible -- any property that doesn't validate is assumed to be an additional property, and validation is successful :). In retrospect, we should probably call this LessPermissiveDraft202012Validator
or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the look of it, LinkML seems to be generating JSON Schema that's compatible with the Draft 7 version of JSON Schema. Here's an example personinfo schema.
Or maybe the LinkML JSON Schema generating logic just needs to update the version of the schema standards it's using.
My reading of https://json-schema.org/understanding-json-schema/structuring.html#ref makes me think that other keywords in `$ref` should be ignored by the validator, but this raises an error with the SaferDraft...Validator. So I'm going to remove it for now.
This PR replaces the use of
definitions
with$defs
in the JSON Schema artifact by upgrading the version of LinkML we use (incorporating the changes made in response to issue linkml/linkml#305).I've also added a JSON Schema validation test to ensure that the generated JSON Schema is valid -- it currently is not, which I suspect is because of #85. I'll keep working on this PR until it fully validates.
Closes #102.