Translation
Generate translation dictionaries, in JSON, from the names in the schema to the names in the generated outputs. Useful where those names matter, such as in a query against a database that follows the schema.
ohi get w3c/prov-oohi linkml to translation --target pydantic \ --to prov-o.translation.json prov-o.linkml.yamlimport ohi_linkml
with ohi_linkml.load_file("prov-o.linkml.yaml") as schema: output = schema.translation(target="pydantic")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.translation({ target: "pydantic" });import eu.neverblink.linkml.generator.options.*import eu.neverblink.linkml.generator.translation.TranslationGeneratorimport eu.neverblink.linkml.schemaview.{SchemaIssues, SchemaView}
val loaded = SchemaView.loadSchemaViewFromUri("prov-o.linkml.yaml")given SchemaView = SchemaIssues.orThrow(loaded)val output = TranslationGenerator().serialize( TranslationGeneratorOptions(target = "pydantic"),)#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_translation( schema, "{\"target\": \"pydantic\"}", &error);linkml_free(output);linkml_free(report);linkml_free(error);linkml_close(schema);Options
Section titled “Options”derived_attributesbooleandefault falseCLI
--derived-attributesScala derivedAttributesWhether classAttributes also lists inherited slots, mixin slots and the slots in the class's slots list. Without it, classAttributes lists only the class's own attributes.
indentation_stepintegerdefault 2CLI
--indentation-stepScala indentationStepThe number of spaces for each level of indentation in the output.
targetstringdefault baseCLI
--targetThe framework of the names in the dictionaries. One of base, uri, scala, graphql, frictionless, ossie, erdiagram, json, typescript, pydantic or docs.