dizzy.generators.json_schema¶
dizzy.generators.json_schema
¶
JSON Schema generator — compiles def/ LinkML sources into JSON Schema contracts.
Driven by the json_schema section of libconfig.yaml:
.. code-block:: yaml
json_schema:
contracts: [commands, queries] # commands | events | queries | models
output_dir: gen_schema # relative to the generate output directory
Omitting the section emits nothing, so a libconfig.yaml written before the
section existed keeps producing byte-identical output. Present-but-empty
(json_schema: {}) opts in with the defaults below.
One schema document is emitted per def/ source, mirroring the def/ layout —
so every class in that source (each command, a query's Input and Output, …) is
addressable as #/$defs/<ClassName>.
resolve_json_schema_settings(config)
¶
Resolve (contracts, output_dir) from a LibConfig, or None if disabled.
Returns None when config is None or carries no json_schema section — the
backwards-compatible default of emitting nothing.
Source code in dizzy/src/dizzy/generators/json_schema.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | |
json_schema_sources(feat, output_dir, contracts)
¶
Map the selected contract kinds to (def_source, relative_output) pairs.
Output paths are relative to the JSON Schema root and mirror def/.
Source code in dizzy/src/dizzy/generators/json_schema.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
write_json_schemas(feat, output_dir, config)
¶
Emit JSON Schema for the contract kinds selected in libconfig.
Returns the list of written files (empty when the json_schema section is absent).
Source code in dizzy/src/dizzy/generators/json_schema.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |