Changing the REST API¶
Core’s REST API has an explicit contract: core/api/openapi.yaml. The server, its tests and the web client are all checked against it.
How the contract is enforced¶
Route coverage:
httpapi.Registerreturns every route it registers; a test fails unless that set equals the operations in the spec.Response and request validation: every REST test in
core/internal/transport/httpapiruns through a middleware (kin-openapi) that validates each response, and each request the server accepted, against the spec. Schemas useadditionalProperties: false, so an undocumented field fails the tests.Generated client:
web/src/lib/api/schema.d.tsis generated from the spec (openapi-typescript) and used throughopenapi-fetch(web/src/lib/api/client.ts).make api-check(part ofmake web-checkand CI) fails when it is stale.
Workflow¶
Change
core/api/openapi.yamltogether with the handler.Cover the new behaviour in the REST tests (they validate against the spec automatically).
make api-generateand commitweb/src/lib/api/schema.d.ts.Update REST API when the change affects users.
make check.
In YAML flow mappings ({ … }), quote descriptions that contain
commas.