ER diagram
Generate a Mermaid entity relationship diagram. Classes become entities, slots ranging over types and enums become their attributes, and slots ranging over classes become relationship lines.
ohi get w3c/prov-oohi linkml to er-diagram --pruning-mode schema \ --to prov-o.mmd prov-o.linkml.yamlimport ohi_linkml
with ohi_linkml.load_file("prov-o.linkml.yaml") as schema: output = schema.er_diagram(pruning_mode="schema")import { readFileSync } from "node:fs";import { LinkML } from "@neverblink/linkml";
const yaml = readFileSync("prov-o.linkml.yaml", "utf8");const { view, report } = LinkML.loadFromString(yaml, {});if (!view) throw new Error(JSON.stringify(report));const output = view.erDiagram({ pruning_mode: "schema" });import eu.neverblink.linkml.generator.options.*import eu.neverblink.linkml.generator.erdiagram.ErDiagramGeneratorimport eu.neverblink.linkml.schemaview.{SchemaIssues, SchemaView}
val loaded = SchemaView.loadSchemaViewFromUri("prov-o.linkml.yaml")given SchemaView = SchemaIssues.orThrow(loaded)val output = ErDiagramGenerator().serialize( ErDiagramGeneratorOptions(pruningMode = PruningMode.Schema),)#include <stddef.h>#include "ohi_linkml.h"
linkml_init_threads();char *report = NULL, *error = NULL;long long schema = linkml_load_file("prov-o.linkml.yaml", NULL, &report, &error);char *output = linkml_er_diagram( schema, "{\"pruning_mode\": \"schema\"}", &error);linkml_free(output);linkml_free(report);linkml_free(error);linkml_close(schema);Options
Section titled “Options”optional_markerbooleandefault trueCLI
--optional-markerScala optionalMarkerWhether to mark optional attributes with a ? after their type. Mermaid supports this from version 11.16 and rejects the whole diagram in older versions.
pruning_modePruningModedefault schemaCLI
--pruning-modeScala pruningModeThe elements of the schema to include in the output.
tree_rootThe elements reachable from the tree root class. Without a tree root, the same asschema.schemaEverything defined in the root schema, and every element reachable from it. This leaves out the unused parts of imported schemas, such as most oflinkml:types.skipEvery element of the root schema and of all its imports.
tree_rootstringCLI
--tree-rootScala treeRootThe class to use as the tree root, instead of the class with tree_root: true in the schema. Only for the tree_root pruning mode.