mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-10 12:21:54 +00:00
A new standalone crate, vectorcraft-apischema, describes a command's parameters: type (number with range and unit, integer, boolean, string, enum, id, id list, color, point, object, array), whether each is required, the default of an omitted value, whether null counts as omitted, the API levels it was added and deprecated at, and the lenient, cost and writes fields. It validates a params object and names the parameter of the first problem, writes the params text, writes the schema in the shape of a JSON Schema 2020-12 object schema, and hashes a set of schemas. CommandSpec gains an optional schema (both builders: the cmd! macro and the text style specs). Session::execute checks the params of a command that has one before anything else, refusing a value of the wrong type, out of range or not in its list, a missing parameter or an unknown key with an error naming the parameter, and fills in defaults; the journal keeps the params as given. engine.commands lists each schema. The six commands in cmd/views.rs have schemas, and their params text is the text the schema writes. schemas::API_VERSION is 1, and a test fails when a schema changes without a new row in SCHEMA_HASHES. Docs: docs/mcp.md (Parameter schemas), docs/target-app-parity.md.