schemas icon indicating copy to clipboard operation
schemas copied to clipboard

Enhance representation of JSON Table Schema as JSON Schema v4

Open pwalsh opened this issue 10 years ago • 2 comments
trafficstars

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:
    • minimum should have a type that exactly matches the type of its encasing field
    • maximum should have a type that exactly matches the type of its encasing field
  • Type and value dependencies in foreignKeys, where:
    • reference.fields should have a type that exactly matches the reference sibling field
    • fields and reference.fields must have values that can be found in field.name of any object in the top-level fields

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.

Here is an example using $ref to create an advanced schema

pwalsh avatar Jan 20 '15 16:01 pwalsh

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)

rufuspollock avatar Jan 21 '15 06:01 rufuspollock

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.

pwalsh avatar Jan 21 '15 14:01 pwalsh