From 7e031125d7511b0c50654c73b0cf8ad88931d190 Mon Sep 17 00:00:00 2001 From: Denys Fedoryshchenko Date: Sat, 31 Jan 2026 20:51:55 +0200 Subject: [PATCH] Add notes about schema extraction Signed-off-by: Denys Fedoryshchenko --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) 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 -------