JSON-LD#

Generate JSONld

class linkml.generators.jsonldgen.JSONLDGenerator(schema: str | ~typing.TextIO | ~linkml_runtime.linkml_model.meta.SchemaDefinition | ~linkml.utils.generator.Generator | ~pathlib.Path, schemaview: ~linkml_runtime.utils.schemaview.SchemaView | None = None, format: str | None = None, metadata: bool = True, useuris: bool | None = None, log_level: int | None = 30, mergeimports: bool | None = True, source_file_date: str | None = None, source_file_size: int | None = None, logger: ~logging.Logger | None = None, verbose: bool | None = None, output: str | None = None, namespaces: ~linkml_runtime.utils.namespaces.Namespaces | None = None, directory_output: bool = False, base_dir: str = None, metamodel_name_map: ~typing.Dict[str, str] = None, importmap: str | ~typing.Mapping[str, str] | None = None, emit_prefixes: ~typing.Set[str] = <factory>, metamodel: ~linkml.utils.schemaloader.SchemaLoader = None, stacktrace: bool = False, include: str | ~pathlib.Path | ~linkml_runtime.linkml_model.meta.SchemaDefinition | None = None, original_schema: ~linkml_runtime.linkml_model.meta.SchemaDefinition = None, context: str = None, **_kwargs)[source]#

Generates JSON-LD from a Schema

Status: incompletely implemented

Note: this is distinct from ContextGenerator, which generates a JSON-LD context

adjust_slot(slot: SlotDefinition) None[source]#
context: str = None#

Path to a JSONLD context file

end_schema(context: str = None, **_) str[source]#

Visited once at the end of generation

@param kwargs: Arguments passed through from CLI – implementation dependent

file_extension: ClassVar[str] = 'jsonld'#
generatorname: ClassVar[str] = 'jsonldgen.py'#

Name of the generator. Override with os.path.basename(__file__)

generatorversion: ClassVar[str] = '0.0.2'#

Version of the generator. Consider deprecating and instead use overall linkml version

original_schema: SchemaDefinition = None#

//github.com/linkml/linkml/issues/871

Type:

See https

requires_metamodel: ClassVar[bool] = True#

Generator queries an instance of the metamodel

uses_schemaloader: ClassVar[bool] = True#

Old-style generator that uses the SchemaLoader and visitor pattern

valid_formats: ClassVar[List[str]] = ['jsonld', 'json']#

Allowed formats - first format is default

visit_class(cls: ClassDefinition) bool[source]#

Visited once per schema class

@param cls: class being visited @return: Visit slots and end class. False means skip and go on

visit_slot(aliased_slot_name: str, slot: SlotDefinition) None[source]#

Visited once for every slot definition in the schema.

@param aliased_slot_name: Aliased name of the slot. May not be unique @param slot: visited slot

visit_subset(ss: SubsetDefinition) None[source]#

Visited once for every subset definition in the schema

#param subset: Subset definition

visit_type(typ: TypeDefinition) None[source]#

Visited once for every type definition in the schema

@param typ: Type definition

CLI#

gen-jsonld#

Generate JSONLD file from LinkML schema.

Status: incomplete

gen-jsonld [OPTIONS] YAMLFILE

Options

--context <context>#

JSONLD context file (default: https://w3id.org/linkml/meta.context.jsonld and <model>.prefixes.context.jsonld)

-V, --version#

Show the version and exit.

-f, --format <format>#

Output format

Default:

'jsonld'

Options:

jsonld | json

--metadata, --no-metadata#

Include metadata in output

Default:

True

--useuris, --metauris#

Use class and slot URIs over model uris

Default:

True

-im, --importmap <importmap>#

Import mapping file

--log_level <log_level>#

Logging level

Default:

'WARNING'

Options:

CRITICAL | ERROR | WARNING | INFO | DEBUG

-v, --verbose#

Verbosity. Takes precedence over –log_level.

--mergeimports, --no-mergeimports#

Merge imports into source file (default=mergeimports)

--stacktrace, --no-stacktrace#

Print a stack trace when an error occurs

Default:

False

Arguments

YAMLFILE#

Required argument