Code

MetaModel

See Datamodel docs for full documentation

class linkml_runtime.linkml_model.meta.SchemaDefinition(*args, _if_missing: Optional[Callable[[jsonasobj2._jsonobj.JsonObj, str], Tuple[bool, Any]]] = None, **kwargs)[source]

a collection of subset, type, slot and class definitions

class linkml_runtime.linkml_model.meta.ClassDefinition(*args, _if_missing: Optional[Callable[[jsonasobj2._jsonobj.JsonObj, str], Tuple[bool, Any]]] = None, **kwargs)[source]

the definition of a class or interface

class linkml_runtime.linkml_model.meta.SlotDefinition(*args, _if_missing: Optional[Callable[[jsonasobj2._jsonobj.JsonObj, str], Tuple[bool, Any]]] = None, **kwargs)[source]

the definition of a property or a slot

Generators

Code for various generators for schema definitions

class linkml.generators.jsonschemagen.JsonSchemaGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], top_class: Optional[str] = None, **kwargs)[source]

Generates JSONSchema documents from a LinkML SchemaDefinition

serialize(**kwargs) str

Generate output in the required format

Parameters

kwargs – Generater specific parameters

Returns

Generated output

class linkml.generators.yamlgen.YAMLGenerator(schema: Union[str, TextIO, linkml_runtime.linkml_model.meta.SchemaDefinition], **kwargs)[source]

A generator that produces a schema as a YAML Document

serialize(validateonly: bool = False, **kwargs) str[source]

Generate output in the required format

Parameters

kwargs – Generater specific parameters

Returns

Generated output

Loaders and Dumpers

class linkml_runtime.dumpers.json_dumper.JSONDumper[source]
dump(element: linkml_runtime.utils.yamlutils.YAMLRoot, to_file: str, contexts: Optional[Union[str, dict, jsonasobj2._jsonobj.JsonObj, List[Union[str, dict, jsonasobj2._jsonobj.JsonObj]]]] = None) None[source]

Write element as json to to_file :param element: LinkML object to be serialized as YAML :param to_file: file to write to :param contexts: JSON-LD context(s) in the form of:

  • file name

  • URL

  • JSON String

  • dict

  • JSON Object

  • A list containing elements of any type named above

dumps(element: linkml_runtime.utils.yamlutils.YAMLRoot, contexts: Optional[Union[str, dict, jsonasobj2._jsonobj.JsonObj, List[Union[str, dict, jsonasobj2._jsonobj.JsonObj]]]] = None, inject_type=True) str[source]

Return element as a JSON or a JSON-LD string :param element: LinkML object to be emitted :param contexts: JSON-LD context(s) in the form of:

  • file name

  • URL

  • JSON String

  • dict

  • JSON Object

  • A list containing elements of any type named above

Parameters

inject_type – if True (default), add a @type at the top level

Returns

JSON Object representing the element

class linkml_runtime.loaders.JSONLoader[source]
loads(source: str, target_class: Type[linkml_runtime.utils.yamlutils.YAMLRoot], *, metadata: Optional[hbreader.FileInfo] = None, **_) linkml_runtime.utils.yamlutils.YAMLRoot

Load source as a string @param source: source @param target_class: destination class @param metadata: metadata about the source @param _: extensions @return: instance of taarget_class

Schema Utils

class linkml_runtime.utils.schemaview.SchemaView(schema: Union[str, linkml_runtime.linkml_model.meta.SchemaDefinition], importmap: Optional[Mapping[str, str]] = None)[source]

A SchemaView provides a virtual schema layered on top of a schema plus its import closure

Most operations are parameterized by imports. If this is set to True (default), then the full import closure is considered when answering

This class utilizes caching for efficient lookup operations.

TODO: decide how to use this in conjunction with the existing schemaloader, which injects into the schema rather than providing dynamic methods.

See:

Utils

Utilities