Open cmungall opened 2 years ago
It would be preferable to avoid using the Schema Builder to assemble a set of classes and fields as other formats do, because we already have the class/field set up via pydantic or dataclasses.
Ideally there would be a generator to output an object/class as linkml, so that converting a schema comprising pydantic (or dataclass
) classes would be a matter of running the classes through the generator / mixing the generator function into the classes / whatever specific mechanism was chosen. A simple solution could be having the classes be subclasses of YAMLRoot
, but without a way to save the transformed schema as linkml, you'd have to do this transform every time you worked with that schema and you would not have the rest of the linkml tools to play with.
From discussion with @ialarmedalien on slack
Approach 1: can convert to json schema and convert from that https://pydantic-docs.helpmanual.io/usage/schema/ --- but that’s not very satisfactory as there would be loss eg inheritance
Approach 2: write something specific to pydantic using https://pydantic-docs.helpmanual.io/usage/exporting_models/