getavalon / core

The safe post-production pipeline - https://getavalon.github.io/2.0
MIT License
214 stars 48 forks source link

Fix #350, specify JSON schema draft version #431

Closed davidlatwe closed 4 years ago

davidlatwe commented 4 years ago

Changes

You may see #350 for detail :)

mottosso commented 4 years ago

Nice one! For completeness, our vendored version of jsonschema won't actually take this into account, but once/if we update then these constraints should kick in? Or do they work already?

davidlatwe commented 4 years ago

Yeah, the keyword const was not working, for example, you could change the container id from pyblish.avalon.container into arbitrary string and it still pass the validation.

For example:

from avalon.vendor import jsonschema

data = {"foo": "bar"}
schema = {"properties": {"foo": {"const": "not-bar"}}}
jsonschema.validate(data, schema)
# No error raised
mottosso commented 4 years ago

Aaah so the current schema was using a too new keyword, and this brings it back to the version we're actually using to validate. Gotcha, that makes sense. Happy with this!