Is there a standard for specifying a version for json schema

Viewed 8593

One of our development partners have asked if there is a way we could specify an interface version within our JSON Schema definition. There isn't a "$version" key so is there a recognised "standard" that we ought to follow (I can't use $id as we are using $ref's elsewhere so the document won't validate any more). We are on Draft-6 so $comment isn't available per-se.

Validation-wise XML Spy is quite happy for me to add a "version" key to the top level, so I could just do that but if there is there a more usual approach I'd rather do that.

2 Answers

There is no standard way to do this defined by JSON Schema. Adding keys to the schema is allowed, as unknown keywords will be ignored by processors.

I usually advise using the $id for versioning, with semantic versioning as part of the $id value. You would have to update your references, but then you could make sure you keep semver expectations.

Often, large scale projects create release bundles, which then have a group of schemas live under a specific semver. For example Human Cell Atlas: https://schema.humancellatlas.org/a

There's also nothing to stop you from creating a new object to contain all your meta info you want to include about a schema, using a key of your choosing at the schema root level.

Snowplow's SchemaVer semantic versioning for schemas is an option.

Related