This uses the schemars crate to automatically generate a JSON schema for our Runefile format.
I've deliberately committed a copy of this schema to the repository (crates/compiler/runefile-schema.json) and added a test that makes sure our hotg_rune_compiler::parse::yaml types are kept in sync with the JSON schema. If it changes at any point (e.g. because we've added docs to an item) then a test will fail, telling us to run cargo xtask update-schema.
We also make sure all the example Runefiles validate using the JSON schema.
Some useful helper programs:
cargo run --example json-schema - print the JSON schema to stdout
cargo run --example validate-runefile-schema ./Runefile.yml - check that the provided Runefile is valid according to our JSON schema
cargo xtask update-schema - update crates/compiler/runefile-schema.json and bindings/web/src/Runefile.ts to match our hotg_rune_compiler::parse::Document
This uses the
schemars
crate to automatically generate a JSON schema for our Runefile format.I've deliberately committed a copy of this schema to the repository (
crates/compiler/runefile-schema.json
) and added a test that makes sure ourhotg_rune_compiler::parse::yaml
types are kept in sync with the JSON schema. If it changes at any point (e.g. because we've added docs to an item) then a test will fail, telling us to runcargo xtask update-schema
.We also make sure all the example Runefiles validate using the JSON schema.
Some useful helper programs:
cargo run --example json-schema
- print the JSON schema to stdoutcargo run --example validate-runefile-schema ./Runefile.yml
- check that the provided Runefile is valid according to our JSON schemacargo xtask update-schema
- updatecrates/compiler/runefile-schema.json
andbindings/web/src/Runefile.ts
to match ourhotg_rune_compiler::parse::Document