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

Closed
opened 2026-03-31 00:25:51 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P3 — OpenAPI client generation

The frontend TypeScript API client is currently maintained manually. When the backend API changes, the frontend types drift until someone manually updates them.

What to do

  1. Confirm the FastAPI app exposes /openapi.json.
  2. Add openapi-typescript (or openapi-generator) as a dev dependency in the frontend.
  3. Add an npm run generate:api script that fetches /openapi.json from a local dev server and generates typed client code into src/api/generated/.
  4. Commit the generated code and add a note in CI to re-run generation when the spec changes.
  5. Replace manual API call wrappers with the generated client where they overlap.

Acceptance criteria

  • npm run generate:api produces a typed TypeScript client
  • Generated client is committed to the repo
  • Frontend compiles without errors after switching to the generated client
  • CI documents (or enforces) regeneration when the OpenAPI spec changes
## Context Roadmap item: P3 — OpenAPI client generation The frontend TypeScript API client is currently maintained manually. When the backend API changes, the frontend types drift until someone manually updates them. ## What to do 1. Confirm the FastAPI app exposes `/openapi.json`. 2. Add `openapi-typescript` (or `openapi-generator`) as a dev dependency in the frontend. 3. Add an `npm run generate:api` script that fetches `/openapi.json` from a local dev server and generates typed client code into `src/api/generated/`. 4. Commit the generated code and add a note in CI to re-run generation when the spec changes. 5. Replace manual API call wrappers with the generated client where they overlap. ## Acceptance criteria - [ ] `npm run generate:api` produces a typed TypeScript client - [ ] Generated client is committed to the repo - [ ] Frontend compiles without errors after switching to the generated client - [ ] CI documents (or enforces) regeneration when the OpenAPI spec changes
AI-Manager added the P3agent-readymediumfeature labels 2026-03-31 00:25:51 +00:00
Author
Owner

[Repo Manager] This issue is already resolved. The frontend package.json includes generate (fetches from live server) and generate:local (from committed openapi.json) scripts using openapi-typescript. Generated types are in src/api/schema.d.ts, committed to the repo. Both CI workflows verify the generated types are up-to-date and run tsc --noEmit to validate compilation. Closing as complete.

[Repo Manager] This issue is already resolved. The frontend package.json includes `generate` (fetches from live server) and `generate:local` (from committed openapi.json) scripts using openapi-typescript. Generated types are in `src/api/schema.d.ts`, committed to the repo. Both CI workflows verify the generated types are up-to-date and run `tsc --noEmit` to validate compilation. Closing as complete.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1518