jsonschema: Changes needed to upgrade from version 2.6 to version 3.0

13 views
Skip to first unread message

Matt Ball

unread,
Jun 25, 2019, 2:31:06 PM6/25/19
to jsonschema - An implementation of JSON Schema for Python
Hi jsonschema members,

I need to upgrade from version 2.6.x to version 3.0.x and was wondering if the existing code will work as-is or whether I need to make particular changes for this upgrade.  Is there a guide on what needs to be done?  If changes are needed, is there a subset of both 2.6 and 3.0 that works under both versions?

Thanks!
-Matt

Julian Berman

unread,
Jun 25, 2019, 8:29:54 PM6/25/19
to Matt Ball, jsonschema - An implementation of JSON Schema for Python
Hi.

The main breaking change is essentially just bumping the default draft (to draft 7). If your schema is strictly correct (i.e. declares its metaschema via $schema), then there shouldn't be anything breaking for you.

(Hopefully your unit tests should confirm for sure though :P)

-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+...@googlegroups.com.
To post to this group, send email to jsons...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jsonschema/b2565aa8-196b-4794-a5dd-d7e15a372b7f%40googlegroups.com.

Matt Ball

unread,
Jun 26, 2019, 12:00:25 PM6/26/19
to Julian Berman, jsonschema - An implementation of JSON Schema for Python
Hi Julian,

I'm getting some breakages, as expected, due to differences in the upgraded schema.

How do I change this code to pin the schema version to an older draft?  The example in the README.rst doesn't appear to show how that draft is specified.  I've seen some code that will explicitly import a particular draft validator (e.g., "from jsonschema import Draft4Validator").  Is that one way to do it?

Thanks for your help!
-Matt



Matt Ball

unread,
Jun 26, 2019, 12:27:32 PM6/26/19
to Julian Berman, jsonschema - An implementation of JSON Schema for Python
Okay, so I was able to fix my failure via this change:

old code:

import jsonschema
jsonschema.validate(contents, schema)

new code:

import jsonschema
jsonschema.Draft4Validator(schema).validate(contents)

Thanks!
-Matt
Reply all
Reply to author
Forward
0 new messages