Skip to content

Add support for inlining multivalued slots as dictionaries in JSON-Schema generation #411

@cmungall

Description

@cmungall

Currently in jsonschemagen inlining of multivalued slots is assumed to be as a list.

i.e we can generate jsonschema that validates:

{"persons":
 [
     {
         "name": "Bob",
         "age": 42,
         "gender": "male"
     },
      {
         "name": "Alice",
         "age": 37,
         "gender": "female"
     }
 ]
}

however, linkml supports inlining as dicts

See https://linkml.io/linkml/schemas/inlining.html for inlining docs

here the identifier slot is used as a key, and the presence of the identifier is optional in the body of the dict

{"persons":
 {
     "Bob": {
         "age": 42,
         "gender": "male"
     },
     "Alice": {
         "age": 37,
         "gender": "female"
     }
 }
}

however, currently jsonschemagen ignores the distinction between list and dict inlining, and always inlines as lists.

This has not been a problem for many schemas "in the wild" since inlining as lists is more common. But it does mean that currently the linkml metamodel (which uses inlining as dict extensively) does not self-validate

To support this the jsonschemagen will need to use the pattern described here:

https://stackoverflow.com/questions/27357861/dictionary-like-json-schema

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions