Skip to main content
Version: latest

agrag.schema.formats.jsonld.to_jsonld

to_jsonld(schema:GraphSchema, *, base_iri:str | None = None) -> dict[str, Any]

Return a JSON-LD OWL vocabulary for a graph schema.

Entity types become OWL classes. Entity properties use entity-qualified IRIs so declarations with the same property name on different types stay distinct. Relation endpoint sets use OWL union classes, preserving alternative domains and ranges instead of implying an intersection. Pattern pairs, symmetry, requiredness, enums and cardinality limits above one use agrag annotations. Empty relation patterns do not create domain or range axioms.

Parameters:

  • schema (GraphSchema) – The schema to export.
  • base_iri (str | None) – Replacement namespace, or None for the schema-name namespace.

Returns:

  • dict[str, Any] – A plain JSON-serializable JSON-LD document.