jsonjsonschemabackwards-compatibility

How can I validate a new JSON schema is backward compatible with previous one?


My question is regarding backwards-compatibility between the new schema and existing data represented in earlier versions of the schema. Is there a library which compares 2 JSON schemas and validates that the new one follows the backward compatibility restrictions (no type changes, adding fields with default values, etc.) ?


Solution

  • The only solution I'm aware of is jsonsubschema. It will check if every schema valid against a schema S1 is also valid against a schema S2. The idea is that when you are considering a change from schema S1, to S2, you would perform this check. If the check passes, then any document which was accepted by the old version of the schema, should also be accepted by the new version of the schema.

    There are some features of JSON Schema not supported by this tool, as detailed in the accompanying research paper.

    Our approach does not handle the following corner cases of the JSON Schema specification: negation, disjunction, and enumeration of object and array schemas; non-regular regex patterns; and recursive references. Our approach detects these corner cases and returns "unknown" for them.