Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

export-jsonschema

Translate mdvs.toml’s [fields] block into a JSON Schema 2020-12 document.

Usage

mdvs export-jsonschema [path] [flags]

Flags

FlagDefaultDescription
path.Directory containing mdvs.toml
--format json|tomljsonOutput format. toml produces a TOML serialization of the same JSON Schema
--output-file FILE(stdout)Write to a file instead of stdout

Global flags (-o, -v, --logs) are described in Configuration.

What it does

export-jsonschema reads mdvs.toml, takes the [fields] block, and translates it into a JSON Schema 2020-12 document. Field types, constraints, path-scoping, and preprocessor stages are all preserved. The output is a valid JSON Schema that any standards-compliant validator can consume.

Build configuration ([embedding_model], [chunking], [search]) and scan settings are not included — JSON Schema only describes the field contract.

Round-tripping with init

export-jsonschema and init --from-jsonschema are designed to round-trip losslessly:

mdvs export-jsonschema ./project --output-file fields.json
mdvs init ./reborn --from-jsonschema fields.json

The new mdvs.toml reproduces the original [[fields.field]] definitions:

  • Field types (strict — String is String, not a permissive set)
  • Constraints (categories, min/max, min_length/max_length, pattern)
  • Path-scoping (allowed, required)
  • Preprocessor arrays (preprocess = ["coerce-to-string"], etc.)
  • The [fields].ignore list

mdvs-specific metadata that JSON Schema 2020-12 doesn’t model is carried in x-mdvs.* extension keys; generic JSON Schema validators ignore them, and init --from-jsonschema reads them back.

Examples

Export to stdout (pipeable)

mdvs export-jsonschema example_kb | jq '.properties | keys'

When writing to stdout, the summary banner is suppressed so the output is directly pipeable.

Export to a file

mdvs export-jsonschema example_kb --output-file fields.json
Exported schema for 37 field(s) → fields.json (json)

Export as TOML

mdvs export-jsonschema example_kb --format toml --output-file fields.toml

The TOML output is the same JSON Schema, serialized via the workspace tomljson crate. It’s interchangeable with the JSON form — init --from-jsonschema fields.toml produces the same result as the JSON file.

Errors

ErrorCause
no mdvs.toml foundConfig doesn’t exist — run mdvs init first
mdvs.toml is invalidTOML parsing or schema error
failed to writeOutput file path is not writable