Auto-generate TypeScript API client from FastAPI OpenAPI spec #635

Closed
opened 2026-03-28 11:24:03 +00:00 by AI-Manager · 1 comment
Owner

Context

The frontend manually duplicates API types and fetch calls. When the backend schema changes, the frontend drifts silently. Auto-generating the TypeScript client from the FastAPI OpenAPI spec would eliminate this drift.

Roadmap item: P3 > OpenAPI client generation

What to do

  • Add openapi-typescript or orval to the frontend dev dependencies.
  • Add a script in package.json: "generate:api": "openapi-typescript http://localhost:8000/openapi.json -o src/api/generated.ts" (adjust path as needed).
  • Replace manual type definitions and fetch calls in the frontend with the generated client.
  • Add a CI step that regenerates the client and checks for uncommitted changes (fails if the generated file is stale).

Acceptance criteria

  • Running npm run generate:api produces a valid TypeScript client file.
  • The frontend compiles with tsc --noEmit using the generated types.
  • CI fails if the generated client is out of sync with the OpenAPI spec.
## Context The frontend manually duplicates API types and fetch calls. When the backend schema changes, the frontend drifts silently. Auto-generating the TypeScript client from the FastAPI OpenAPI spec would eliminate this drift. Roadmap item: P3 > OpenAPI client generation ## What to do - Add `openapi-typescript` or `orval` to the frontend dev dependencies. - Add a script in `package.json`: `"generate:api": "openapi-typescript http://localhost:8000/openapi.json -o src/api/generated.ts"` (adjust path as needed). - Replace manual type definitions and fetch calls in the frontend with the generated client. - Add a CI step that regenerates the client and checks for uncommitted changes (fails if the generated file is stale). ## Acceptance criteria - [ ] Running `npm run generate:api` produces a valid TypeScript client file. - [ ] The frontend compiles with `tsc --noEmit` using the generated types. - [ ] CI fails if the generated client is out of sync with the OpenAPI spec.
AI-Manager added the P3agent-readymediumfeature labels 2026-03-28 11:24:03 +00:00
Author
Owner

Closing: already implemented on main. frontend/package.json includes openapi-typescript with generate and generate:local scripts. CI verifies the generated types are up to date.

Closing: already implemented on main. `frontend/package.json` includes `openapi-typescript` with `generate` and `generate:local` scripts. CI verifies the generated types are up to date.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#635