ehn-dcc-development / eu-dcc-schema

Schema for the ehn DCC payload
Apache License 2.0
164 stars 59 forks source link

DGC Schema semantic version not in $id #72

Closed miguelzapaton closed 3 years ago

miguelzapaton commented 3 years ago

Hello again,

I just started validating with the new DGC Schema version 1.0.1 in parallel with the older version 1.0.0

Some of my test JSON data files now have "ver": "1.0.0", others "ver": "1.0.1".

I use the Ajv validator but I'm sure other tools will show a similar behaviour:

As the schema $id of version 1.0.0 and version 1.0.1 are identical, Ajv complains when I'm trying to load the second schema in the same instance with ajv.addSchema(schema2-N, 'semver') or ajv.compile(schema2-N).

This makes it impossible to use the same Ajv instance for all DGC Schema versions. From an implementer's perspective this is quite impractical and resource inefficient (even when instance caching is used).

Ajv has wonderful mechanisms for managing multiple schemas and versions:

https://ajv.js.org/guide/managing-schemas.html

However, they seem to rely on different schema $id values.

As I understood it's generally a good idea with JSON Schema to include the semver (-> schemaver) in the $id.

Some further external links for interested people:

http://docs.mediachain.io/publishing/schema-recommendations

http://docs.snowplowanalytics.com/docs/pipeline-components-and-applications/iglu/common-architecture/schemaver/

Miguel

jschlyter commented 3 years ago

IMHO, since all changes in schema v1 (with semver) must be backwards compatible, the id should not matter. if/when we move to schema v2 we need a new id.

miguelzapaton commented 3 years ago

I agree. For the moment it's all backwards compatible as the "tt" change in 1.0.1 only affects the valuesets and not the structure.

The good news is that's not too late to put a "schemaver" in the $id once v2 is necessary, e.g.:

"$id": "https://id.uvci.eu/DGC.schema-2-0-0.json",
gabywh commented 3 years ago

Closed as no further comments