Skip to content

Latest commit

 

History

History
69 lines (52 loc) · 2.38 KB

File metadata and controls

69 lines (52 loc) · 2.38 KB

Compiling

Warning

JSON Schema Draft 3 and older are not supported at this point in time.

jsonschema compile <schema.json|.yaml> [--http/-h] [--verbose/-v] [--debug/-g]
  [--resolve/-r <schemas-or-directories> ...] [--extension/-e <extension>]
  [--ignore/-i <schemas-or-directories>] [--fast/-f] [--default-dialect/-d <uri>]
  [--minify/-m] [--json/-j] [--include/-n <name>] [--entrypoint/-p <pointer|uri>]

The validate command will first compile the schema into an optimised low-level form (the compiled template) before evaluating using the Blaze high-performance JSON Schema compiler. This command allows you to separately compile the schema and print the low-level template to standard output.

The low-level template is not stable across versions of this JSON Schema CLI. While it might work, we don't necessarily support evaluating templates generated with another version of this tool.

You can pass the compiled template to the validate command to avoid expensive schema compilation if you need to perform validation multiple times with the same schema.

Tip

The compiled template is also consumable from any JavaScript engine through the Blaze JavaScript port, a pure-JavaScript evaluator for browsers and JavaScript runtimes like Node.js. Compile once with this CLI and evaluate anywhere.

Warning

By default, schemas are compiled in exhaustive mode, which results in better error messages and annotations, at the expense of speed. The --fast/-f option makes the schema compiler optimise for speed, at the expense of error messages.

Compile a standalone JSON Schema in exhaustive mode

jsonschema compile path/to/my/schema.json > template.json

Compile a standalone JSON Schema in optimised mode

jsonschema compile path/to/my/schema.json --fast > template.json

Compile a JSON Schema resolving one of its dependencies

jsonschema compile path/to/my/schema.json --resolve other.json > template.json

Compile a JSON Schema to a C/C++ header file

jsonschema compile path/to/my/schema.json --include MY_SCHEMA > my_schema.h

Compile a specific subschema by JSON Pointer

jsonschema compile path/to/my/schema.json --entrypoint '/$defs/MyType' > template.json