importing a validator that defaults to the latest schema version

25 views
Skip to first unread message

Per Unneberg

unread,
Aug 12, 2018, 4:29:20 AM8/12/18
to jsonschema - An implementation of JSON Schema for Python
Hi,

I'm extending a property validator based on the code in the FAQ, to be used in an application. Here, a specific schema version is imported. Is there any way to import the latest schema version by default? Basically, I want to avoid hard-coding the specific version and fall back on the latest version supported by jsonschema. Is this possible?

Cheers,

Per

Julian Berman

unread,
Aug 15, 2018, 2:01:29 AM8/15/18
to Per Unneberg, jsonschema - An implementation of JSON Schema for Python
There isn't currently, but draft versions aren't (haven't been) backwards compatible, so it's not completely reasonable to do -- especially since your schema should be specifying a `$schema` property pointing at their meta schema, which you'd need to update anyways. If you are doing the latter though (setting a `$schema` property), when you change the `$schema` property, if you use `jsonschema.validators.validator_for` you will get the appropriate versioned validator (assuming jsonschema supports it).

Lemme know if that makes sense.

-J

--
You received this message because you are subscribed to the Google Groups "jsonschema - An implementation of JSON Schema for Python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsonschema+unsubscribe@googlegroups.com.
To post to this group, send email to jsons...@googlegroups.com.

Per Unneberg

unread,
Aug 16, 2018, 5:04:19 AM8/16/18
to jsonschema - An implementation of JSON Schema for Python
Thanks for the heads up; yes that makes sense and your answer provided the solution I needed.

Cheers,

Per
To unsubscribe from this group and stop receiving emails from it, send an email to jsonschema+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages