tcompa / pydantic-and-friends

Working repo for "pydantic and friends" group at Zurich hackaton
1 stars 0 forks source link

Question: what does linkml do that JSON Schemas don't? #4

Open tcompa opened 8 months ago

gnodar01 commented 8 months ago

Short answer, it seems nothing (in terms of capability): https://linkml.io/linkml/generators/json-schema.html

The pros of using linkml is the generators (generate python, pedantic, typescript, java), and that it allows for inheritance (unrolled when converting to json schema), and inlining.

tcompa commented 8 months ago

For the record, see also https://linkml.io/linkml/faq/why-linkml.html#why-should-i-use-linkml-over-json-schema:

JSON-Schema is a fantastic framework for validating JSON documents. If your primary use case is validating JSON documents then by all means keep using it!

However, if any of the following apply to you, you may want to consider LinkML - and remember, you can always compile your LinkML schema down to JSON-Schema!

  • You want to make use of inheritance/polymorphism
  • you want a language with a simple core based around familiar concepts of classes and fields (slots)
  • you want to make your data more FAIR (Findable Accessible Interoperable Reusable), for example, by annotating schema elements with IRIs
  • you want to use JSON-LD but don’t want to coordinate separate JSON-Schema and JSON-LD context documents - LinkML is an all-in-one-solution!
  • you want enums to be aligned with ontologies or standard vocabularies
  • you need to use dynamic enumerations
  • you want your data model to be used in other frameworks than JSON - e.g. TSVs, SQL databases, Triple stores, graph databases

When making your decision, you should weigh factors such as the fact that things that can be expressed in one framework may not be expressible in the other.

See also FAQ entries in modeling which compare some similar constructs.