-
Notifications
You must be signed in to change notification settings - Fork 49
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
Avalon's schema validation module does not support Draft-6 validation keywords #350
Comments
Happy to see a PR for this; the tests should kick in to see if anything immediately breaks. |
Dumping additional note:
Currently all the schemas are having this meta-schema In fact, maybe we could solving this issue by changing all meta-schema to I think this is the best option :) |
Example: After update the
import jsonschema # version 3.0
data = {"foo": "bar"}
schema = {"$schema": "http://json-schema.org/schema#",
"properties": {"foo": {"const": "foobar"}}}
jsonschema.validate(data, schema) # Auto validating with latest Draft
# Error raised
import jsonschema # version 3.0
data = {"foo": "bar"}
schema = {"$schema": "http://json-schema.org/draft-04/schema#",
"properties": {"foo": {"const": "foobar"}}}
jsonschema.validate(data, schema) # Auto validating with Draft 4
# No error :) |
We might have to remove install_requires =
attrs>=17.4.0
pyrsistent>=0.14.0
six>=1.11.0
functools32;python_version<'3' |
If it means asking the end-user to install an additional dependency, it's not worth the gain of validating against |
Not affect to production in most cases, yes.
Yeah, updating from avalon.vendor import jsonschema
# Validation: The value of "foo" must be "bar"
data = {"foo": "not-bar"}
schema = {"$schema": "http://json-schema.org/schema#",
"properties": {"foo": {"enum": ["bar"]}}} # Use `enum` instead of `const`
jsonschema.validate(data, schema)
# Error raised And for clarity, I suggest we also change the value of |
Problem
Some of Avalon's schema were using the keyword
const
, which was introduced in JSON schema Draft 6, which requirejsonschema==3.0.0
to work, and the current vendoring version ofjsonschema
in Avalon is version2.4.0
.Those not supported keyword will not functioning, which means no
jsonschema.ValidationError
raised.See the following example:
Above example code will raise
jsonschema.ValidationError
if you use the latest version (3.0.0) downloaded from jsonschema github repo.So, if someone changed the default value which provided by Avalon, and thought it's okay since no error raised, will be an issue in the feature, when Avalon update the
jsonschema
vendor module, someone's pipeline will broke.For example, in my case, I changed the
container id
frompyblish.avalon.container
topyblish.avalon.sub-container
, for assets likesetdress
type, which has nested container.Implementation
Eventually, Avalon will update
jsonschema
vendor module at some point, and when the time comes, we could let TDs to useDraft4Validator
for the time being and pop warning.Example code:
The text was updated successfully, but these errors were encountered: