Repository navigation
build(gui): generated OpenAPI TypeScript client + CI drift gate - #205
Merged
Merged
Conversation
Add a typed client for the local API, generated from its OpenAPI spec:
- scripts/export_openapi.py dumps a deterministic fiberpath_gui/openapi.json
(sorted keys, version normalised to a placeholder so release bumps don't
churn the artifact).
- openapi-typescript generates src/api/schema.ts; a thin openapi-fetch
wrapper (src/api/client.ts) exposes createApiClient(baseUrl).
- npm scripts: api:generate{,:spec,:client}. openapi-typescript runs via
pinned npx (its TS ^5 peer conflicts with the repo's TS 6); openapi-fetch
is a runtime dependency.
- CI drift gate, split by toolchain: the backend job regenerates the spec
and the GUI job regenerates the client, each failing on git diff. The
frontend's view of the backend can no longer silently rot.
Part of #191 (delivers the client + drift gate). The remaining acceptance —
retiring the hand-maintained response types (lib/schemas.ts, lib/tauri-types.ts)
— lands with #193, when the GUI actually consumes this generated client.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #191 (Epic #195). Delivers the typed client + drift gate; the remaining acceptance — retiring the hand-maintained response types (
lib/schemas.ts,lib/tauri-types.ts) — lands with #193, when the GUI actually consumes this client.What
scripts/export_openapi.py→ deterministicfiberpath_gui/openapi.json(sorted keys;info.versionnormalised to a placeholder so release bumps don't churn the artifact — the served/openapi.jsonstill reports the real version).fiberpath_gui/src/api/schema.tsgenerated byopenapi-typescript;client.tsis a thinopenapi-fetchwrapper exposingcreateApiClient(baseUrl).api:generate{,:spec,:client}.openapi-typescriptruns via pinned npx (@7.13.0) because itstypescript@^5peer conflicts with the repo's TS 6 — matching the existingjson-schema-to-typescriptpattern;openapi-fetchis a runtime dep.git diff --exit-codesopenapi.json; the GUI job regenerates the client andgit diff --exit-codesschema.ts. Either drift fails CI.Review gate
Reviewed by an independent adversarial subagent (SHIP-WITH-NITS, no blocking). It proved the gate catches drift both ways: a backend docstring/model change flipped the spec gate to RC=1; renaming a field in
openapi.jsonflipped the client gate to RC=1 — both reverted, tree left clean. Nits addressed (determinism note added; acceptance scoping corrected to "Part of #191").Verification
tscclean · vitest 625 passed · drift gate clean on regen (zero diff), and fails on injected drift (verified).