Skip to content

build(gui): generated OpenAPI TypeScript client + CI drift gate - #205

Merged
CameronBrooks11 merged 1 commit into
mainfrom
build/openapi-client-191
Jun 26, 2026
Merged

CameronBrooks11 merged 1 commit into
mainfrom
build/openapi-client-191

Conversation

@CameronBrooks11

Copy link
Copy Markdown
Member

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 → deterministic fiberpath_gui/openapi.json (sorted keys; info.version normalised to a placeholder so release bumps don't churn the artifact — the served /openapi.json still reports the real version).
  • fiberpath_gui/src/api/schema.ts generated by openapi-typescript; client.ts is a thin openapi-fetch wrapper exposing createApiClient(baseUrl).
  • npm scripts api:generate{,:spec,:client}. openapi-typescript runs via pinned npx (@7.13.0) because its typescript@^5 peer conflicts with the repo's TS 6 — matching the existing json-schema-to-typescript pattern; openapi-fetch is a runtime dep.
  • CI drift gate, split by toolchain: the backend job regenerates the spec and git diff --exit-codes openapi.json; the GUI job regenerates the client and git diff --exit-codes schema.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.json flipped the client gate to RC=1 — both reverted, tree left clean. Nits addressed (determinism note added; acceptance scoping corrected to "Part of #191").

Verification

  • ruff clean · GUI tsc clean · vitest 625 passed · drift gate clean on regen (zero diff), and fails on injected drift (verified).

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.
@CameronBrooks11
CameronBrooks11 merged commit dcb0ab6 into main Jun 26, 2026
18 checks passed
@CameronBrooks11
CameronBrooks11 deleted the build/openapi-client-191 branch June 26, 2026 04:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant