linkml / schema-automator

Automated assistance for the schema development lifecycle
https://linkml.io/schema-automator/
BSD 3-Clause "New" or "Revised" License
33 stars 12 forks source link

jsonschema oneOf -> linkml:union_of (slightly different definitions?) #107

Open sierra-moxon opened 1 year ago

sierra-moxon commented 1 year ago

Running schema-automator import-json-schema.
JSONSchema has a "oneOf" definition:

Screen Shot 2022-10-10 at 10 45 37 AM

schemauto -import-json-schema vrs.json results in:

Screen Shot 2022-10-10 at 10 45 55 AM

https://linkml.io/linkml-model/docs/union_of/ indicates that the domain element consists exactly of the members of the element in the range.

I think JSONSchema oneOf means "if the data matches any one of these independent schemas, then allow it, else fail" in terms of validation. The LinkML definition of union_of implies that the data must match all of the members in the array. Am I reading this correctly?

cmungall commented 1 year ago

I think the linkml metamodel could be better specified, but they are essentially the same

however, since 1.3 it is better to map json schema composition (https://json-schema.org/understanding-json-schema/reference/combining.html) to linkml boolean operators https://linkml.io/linkml/faq/modeling.html#how-do-i-do-the-equivalent-of-json-schema-composition

nlharris commented 1 year ago

So is this a bug, or does the documentation need improving, or what?