diff --git a/README.md b/README.md index 9bdc1b8..22e5d47 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,41 @@ json = kcidb_io.new() kcidb_io.schema.validate(json) ``` +Exporting the JSON schema +------------------------- + +The current schema is available as a JSON Schema dictionary on the version +class. The latest schema is exposed as `kcidb_io.schema.LATEST`. + +Export the latest schema to a file: + +```bash +python3 - <<'PY' +import json +from kcidb_io import schema + +v = schema.LATEST +with open(f"kcidb-io.schema.v{v.major}.{v.minor}.json", "w") as f: + json.dump(v.json, f, indent=2, sort_keys=True) +PY +``` + +Compatibility notes +------------------- + +The schema is validated in this library using JSON Schema Draft-07. The +exported schema JSON does not include a `$schema` field; if a validator +requires one, add: + +```json +{ + "$schema": "http://json-schema.org/draft-07/schema#" +} +``` + +The schema uses `$defs` and the `uri` string format. If your validator supports +format checking, enable it to validate `uri` values. + Hacking -------