feat: generate flow-template and policy JSON schemas from the API#296
Conversation
The two static JSON Schema assets were hand-maintained and drifted from the schemas the API enforces (e.g. the 'decision' attestation type was missing from flow-template). Generate them from the source-of-truth API endpoints instead: - scripts/update_schemas.py fetches both schemas and writes them verbatim; --check fails when the committed files drift. - flow-template moves to the versioned path schemas/flow-template/v1.json to match its $id; redirects keep the old URLs resolving. - update-schemas.yml regenerates on a schedule and opens a PR on drift. Closes #293
|
Preview deployment for your docs. Learn more about Mintlify Previews.
|
|
Claude finished @dangrondahl's task in 1m 43s —— View job PR Review: Generate flow-template and policy JSON schemas from the API
Nice, well-structured PR. The script, tests, workflow, redirects, and URL updates all look correct. One content issue to flag: Improvement
The generated
Since the whole point of this PR is to bring the schemas in sync with the API, it would be good to also update the prose reference to match. Suggested fix for both lines: Everything else looks good
|
|
What
Generate the two static JSON Schema assets from the Kosli API (the source of truth in
kosli-dev/server) instead of hand-maintaining them.schemas/flow-template/v1.jsonGET /api/v2/schemas/flow-template/v1schemas/policy/v1.jsonGET /api/v2/schemas/environment-policy/v1Why
The committed copies drifted from what the API enforces. Concrete example: the
decisionattestation type (server#5988) is returned by the API but was missing from the hand-editedschemas/flow-template.json. Regenerating from the API also brings the policy schema up to date (draft 2020-12,$defs).Changes
scripts/update_schemas.py— fetches both schemas from the public API endpoints and writes them verbatim (pretty-printed).--checkexits non-zero when the committed files drift.schemas/flow-template/v1.jsonso the file matches the API's$id(.../schemas/flow-template/v1), mirroring the existing policy layout. Two redirects keep old URLs resolving:/schemas/flow-template/v1→/schemas/flow-template/v1.json/schemas/flow-template.json→/schemas/flow-template/v1.json/schemas/flow-template/v1.json(6 occurrences across 5 pages)..github/workflows/update-schemas.yml— regenerates on a daily schedule (and manual dispatch) and opens a PR when the files drift, matching theupdate-cli-docs.ymlpattern.tests/test_update_schemas.py— offline unit tests for the generator (render formatting, write mode, drift detection).Decisions confirmed with maintainer
$id: move to the versioned path, write verbatim (mirror policy).Testing
python scripts/update_schemas.py --check→ ok, exit 0pytest tests/→ 22 passedmint broken-links→ only one pre-existing unrelated broken link (/getting_started/service-accountsinworking_with_controls.mdx, which already has a redirect)Acceptance criteria
Closes #293