schemas
schemas copied to clipboard
Enhance representation of JSON Table Schema as JSON Schema v4
I've recently added constraints, primaryKey and foreignKeys to json-table-schema.json. This brings in much more of the current spec, but still leaves some things that are more difficult to represent as JSON Schema:
- Type dependencies in constraints, where:
minimumshould have a type that exactly matches the type of its encasingfieldmaximumshould have a type that exactly matches the type of its encasingfield
- Type and value dependencies in foreignKeys, where:
reference.fieldsshould have a type that exactly matches thereferencesiblingfieldfieldsandreference.fieldsmust have values that can be found infield.nameof any object in the top-levelfields
I asked about this on the JSON Schema mailing list and I know see how this can be represented in JSON Schema, but it will make the reference file here vastly more complex: it will become a directory with many sub-schema files that are referenced in the master schema under certain conditions.
Hmmmm - let's think e.g.:
- is also worth thinking how good the json schema implementations are - not all of them support the full spec
- it is possible for the validators of json table schema in python / javascript etc to do their own constraint checking in addition to using json schema (and that may be simpler in some cases that contorting json schema to support what we want)
Yes, the available JSON Schema validators in python and javascript don't support all features of the spec.
In any event, I don't think this is something that needs to be acted on, but I wanted to dump this knowledge here for reference, as the JSON Schema v4 json-table-schema.json in this repo is currently the canonical reference implementation of the JSON Table Schema spec.