carp.core-kotlin icon indicating copy to clipboard operation
carp.core-kotlin copied to clipboard

Replace JSON pointer URI fragment with anchor references in JSON schemas

Open Whathecode opened this issue 3 years ago • 1 comments

The json-schema-validator library we want to use for JSON schema validation does not yet support named anchor lookup for the metaschema we are using (draft 2019/09).

As a workaround, we currently use JSON pointer URIs within our schemas to point to these anchors.

The current locations are:

  • TriggeredTask.json to point to TaskControl#Control
  • In application service request objects (e.g., DataStreamServiceRequest.json) to point to definitions within the same file
  • JsonSchemaTest.kt to load the reponse schemas of requests

Once json-schema-validator provides support for this, we can upgrade and replace these references with named anchor references.

Whathecode avatar Jan 24 '22 15:01 Whathecode

This works partially with a bugfix for json-schema-validator introduced in 1.0.67. All external references to anchors now use the anchor notation. However, internal anchor references still fail and currently thus still use the full path notation.

Whathecode avatar Mar 07 '22 16:03 Whathecode

However, internal anchor references still fail and currently thus still use the full path notation.

With the latest version of JSON schema validator this now also works for internal references. However, it begs the question whether we want to replace all internal references with anchors (and thus add anchors where there currently aren't any).

Are there conventions for when to use an anchor and when not?

Whathecode avatar Oct 26 '24 13:10 Whathecode