taskcluster / react-schema-viewer

React Schema Viewer takes a schema ('json' | 'joi') as input and uses it to generate comprehensible views
Mozilla Public License 2.0
14 stars 9 forks source link

Add support for `$id` as well as `id` #23

Closed djmitche closed 5 years ago

djmitche commented 5 years ago

The current version only works with v6 schemas (with schema.id), but not v7 schemas (which have schema.$id).

arshadkazmi42 commented 5 years ago

can you provide some more info for getting started with this bug. I would like to take a look into this.

djmitche commented 5 years ago

Sure -- sorry, I filed it quickly as a reminder to myself.

JSON-schema has a few versions, and in Draft-06 a schema had an id property giving its id, while in Draft-07 this was renamed to $id.

It's not practical to know, given a schema, which draft it corresponds to (its $schema property may point to some other, custom schema, as we do in taskcluster). However, it shouldn't be too hard to always look for either $id or, if that's missing, for id.

So basically this bug involves changing references that look for schema.id to look first for $id.

arshadkazmi42 commented 5 years ago

Thank you for the detailed info @djmitche I am planning on doing a change something like this

schema.id -> schema.$id ? schema.$id : schema.id
djmitche commented 5 years ago

That sounds perfect.