Publish a JSON Schema for node YAML #121

Merged
Claude merged 2 commits from feat/yaml-schema into feat/yaml-nodes 2026-10-15 15:52:24 +00:00
Collaborator

YN-4. scripts/node_schema.py writes nodes/node.schema.json (draft 2020-12, $id the raw URL on main) from the generator's own tables, so boards, pins, fields and limits live in one place. To drive both, yaml_node.py's per-field defaults and limits moved into a fieldSpecs table that the parser also reads, and the pin rules into one pin_problem function. Per-board pin enums come from if/then on node.board, with strapping and CAN-board pins left out and input-only pins limited to inputs. The rules a schema cannot express are listed in its top-level description.

The generator gains no runtime dependency. jsonschema is used by the tests only and is installed in CI, where a new step also regenerates the schema and fails on a diff. One README line points front-end authors at the schema.

One behaviour note: a frequency above 312500 Hz now fails the plain range check ("not between 1 and 312500") instead of the old "fewer than 8 bits of duty" message. The limit is the same.

Tested: new test_node_schema.py checks the schema is valid, that the sample and all fixtures validate, that strapping, CAN-board and input-only pins and out-of-type fields are rejected, and that the committed file matches the generator. Breaking the strapping rule fails two of them. All 24 Python tests pass locally, with jsonschema in a throwaway venv; without it the 6 schema-validation tests skip. The sample and fixtures still build.

YN-4. `scripts/node_schema.py` writes `nodes/node.schema.json` (draft 2020-12, `$id` the raw URL on main) from the generator's own tables, so boards, pins, fields and limits live in one place. To drive both, `yaml_node.py`'s per-field defaults and limits moved into a `fieldSpecs` table that the parser also reads, and the pin rules into one `pin_problem` function. Per-board pin enums come from `if`/`then` on `node.board`, with strapping and CAN-board pins left out and input-only pins limited to inputs. The rules a schema cannot express are listed in its top-level `description`. The generator gains no runtime dependency. `jsonschema` is used by the tests only and is installed in CI, where a new step also regenerates the schema and fails on a diff. One README line points front-end authors at the schema. One behaviour note: a `frequency` above 312500 Hz now fails the plain range check ("not between 1 and 312500") instead of the old "fewer than 8 bits of duty" message. The limit is the same. Tested: new `test_node_schema.py` checks the schema is valid, that the sample and all fixtures validate, that strapping, CAN-board and input-only pins and out-of-type fields are rejected, and that the committed file matches the generator. Breaking the strapping rule fails two of them. All 24 Python tests pass locally, with `jsonschema` in a throwaway venv; without it the 6 schema-validation tests skip. The sample and fixtures still build.
Publish a JSON Schema for node YAML
Some checks failed
Build and test / release (pull_request) Has been cancelled
Build and test / build (pull_request) Has been cancelled
8017ddd541
Author
Collaborator

Review findings addressed in the follow-up commit: bind, frequency and hold cases added to the schema tests; commonFields back to a set; duplicate index and pin added to the generator-only rules in the schema description; the in-test stale check dropped so the CI diff step is the one check. Duplicate-index and the Python float/newline quirks otherwise need no change.

Review findings addressed in the follow-up commit: bind, frequency and hold cases added to the schema tests; `commonFields` back to a set; duplicate index and pin added to the generator-only rules in the schema description; the in-test stale check dropped so the CI diff step is the one check. Duplicate-index and the Python float/newline quirks otherwise need no change.
Cover binds and limits in the schema tests
All checks were successful
Build and test / build (pull_request) Successful in 5m10s
Build and test / release (pull_request) Has been skipped
8b67eed4cf
Claude merged commit 702359a872 into feat/yaml-nodes 2026-10-15 15:52:24 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rob/CampervanControlSystems!121
No description provided.