10

I have a repository that contains versioned json-schemas so for each type of schema I could have several revisions: v1, v2, v3 etc. I want to test schemas for backwards compatibility, so that any event which was valid for v1 schema is guaranteed to be valid for a v2 schema.

To do that, I need to ensure that properties are only added and never removed, non-required properties never become required and so on. Is there any library for node.js available to achieve my goal?

Petr
  • 5,999
  • 2
  • 19
  • 25

1 Answers1

0

Naive question: is it something you need to do programmaticaly (i.e. regularly) or is just singular check whenever you introduce a new version ?

If it's "singular", you may try to use this website on your v1. It will generate a "fake" json based on your imposed schema. Then, by passing it to your upgraded schema versions, you should be able to make sure backward compatibility is achieved.

Note I have never used the tool myself so I don't know to which extent it deals with non-"required" fields...

Sorry if I missed your point ;)

Limtorak
  • 81
  • 5
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/32620710) – Adam Sep 07 '22 at 03:35
  • in my case i want to do it programmatically and on-demand. i want to ask programmatically "is schema X compatible with schema Y for reader A and writer B" – simbo1905 Dec 14 '22 at 10:59