linkml / linkml-runtime

Runtime support for linkml generated models
https://linkml.io/linkml/
Creative Commons Zero v1.0 Universal
24 stars 23 forks source link

Check inlined or inlined_as_list slots only if range is class in schema #240

Closed pkalita-lbl closed 1 year ago

pkalita-lbl commented 1 year ago

The root cause of https://github.com/linkml/linkml/issues/1266 is that the schema includes a slot defined like so:

slots:
  see_also:
    range: uriorcurie
    description: Links to useful info
    multivalued: true
    inlined_as_list: true

When JsonSchemaGenerator switched from using SchemaLoader to SchemaView it introduced a call to SchemaView.is_inlined(). Currently that method will return True for the above slot definition. Regardless of whether you should put inlined_as_list on a slot with a type range (as opposed to a class range), that feels like the wrong answer to me (I can already hear @cmungall saying "Postel-ian"). A uriorcurie can't really be inlined because there's nothing to inline, right?

The change here swaps the order of some logical checks in is_inlined so that the inlined and inlined_as_list metaslots are only checked if the range is a class in the schema. I added a test that attempts to enumerate all the possibilities.

Fixes https://github.com/linkml/linkml/issues/1266