learningtapestry/metadataregistry

How to associate a third party controlled vocabulary with our labels in json-schema?

Closed this issue · 2 comments

In my call yesterday with CTI, the question was raised by @stuartasutton as to how we can provide linked data references to remote controlled vocabularies in our json-schema validation system.

For example, right now we have agentCategory defined as:

agentCategory: [labels,...]

I think those labels have actually been defined at some remote URL already. So it would be great if we could provide a URL reference to that. The simplest way seemed to be using the "description" field to provide that information.

Stuart thought there might be a more formal method to making the association in a way that was machine-readable?

My only concern was that if we just provided a URL to the labels, then programmers have to hop around between different schema files to figure out what's permissible, and that makes their jobs harder..

Thoughts? Ideas?

Normally we use the $ref property to define a external reference, or to 'dry' our schemas.

Example:

// some-schema.json
"definitions": {
  "agentCategory": {
     "type": "string",
     "enum": [ .... ]
   }
}

// other-schema.json
"myfield": { "$ref": "some-schema.json#definitions/agentCategory" }

but there is this caveat of having to jump on differente schemas.
We can:

  • define this way using pure json-schemas only
  • on the application side use erb templates to generate the schemas, embeding the definitions (using partials). From the code point-of-view, it will be deduplicated, but the generated schemas would have all definitions replicated on them (that works for schemas we 'own').

I did a proof-of-concept with the erb templates already, but did not used at the end (can easily rebuild it).

On the PR above we added an engine for loading schemas from composable ERB templates. I.e, we can add embeded definitions or resolve ref dinamically.

We refactored all the current schemas to use this new engine.

Using this we could reuse, partially, the definitions we generated on https://github.com/learningtapestry/json-schema.org

I'll close this for now, but if something new comes up we might reopen/rediscuss.