JSON Schema
Generate a JSON Schema.
ohi get w3c/prov-oohi linkml to json-schema --tree-root Entity \ --to prov-o.schema.json prov-o.linkml.yamlimport ohi_linkml
with ohi_linkml.load_file("prov-o.linkml.yaml") as schema: output = schema.json_schema(tree_root="Entity")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.jsonSchema({ tree_root: "Entity" });import eu.neverblink.linkml.generator.options.JsonSchemaGeneratorOptionsimport eu.neverblink.linkml.generator.jsonschema.JsonSchemaGeneratorimport eu.neverblink.linkml.schemaview.{SchemaIssues, SchemaView}
val loaded = SchemaView.loadSchemaViewFromUri("prov-o.linkml.yaml")given SchemaView = SchemaIssues.orThrow(loaded)val output = JsonSchemaGenerator().serialize( JsonSchemaGeneratorOptions(treeRoot = Some("Entity")),)#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_json_schema( schema, "{\"tree_root\": \"Entity\"}", &error);linkml_free(output);linkml_free(report);linkml_free(error);linkml_close(schema);Options
Section titled “Options”include_nullbooleandefault falseCLI
--include-nullScala includeNullWhether optional values and compact dictionary entries with nothing beyond the key may be null.
indentation_stepintegerdefault 2CLI
--indentation-stepScala indentationStepThe number of spaces for each level of indentation in the output.
metadata_languagestringdefault enCLI
--metadata-languageScala metadataLanguageThe language of the titles and descriptions in the output, for schemas with text in more than one language.
openbooleandefault falseCLI
--openWhether every class allows properties beyond the ones in the schema. Classes whose extra_slots allows them allow them anyway.
tree_rootstringCLI
--tree-rootScala treeRootThe class at the root of the JSON Schema, instead of the class with tree_root: true in the schema.
tree_root_inline_typestringCLI
--tree-root-inline-typeScala treeRootInlineTypeHow the tree root class appears at the root of the JSON Schema, instead of its tree_root_as extension. One of plain, optional, list, compact_dict or simple_dict.