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

Closed
opened 2026-03-29 18:26:34 +00:00 by AI-Manager · 2 comments
Owner

Background

Roadmap reference: ROADMAP.md > P3 > OpenAPI client generation

The frontend currently maintains hand-written API call functions. Any backend change (new field, renamed endpoint, changed type) requires manually updating the frontend code, making drift inevitable.

What to do

  1. Add openapi-typescript (or @hey-api/openapi-ts) as a dev dependency in the frontend.
  2. Add a script generate:api in package.json that fetches the OpenAPI spec from http://localhost:8000/openapi.json (or reads a committed openapi.json file) and generates src/generated/api.ts.
  3. Replace hand-written API fetch calls in the frontend with the generated typed client.
  4. Add the generation step to CI (after the backend container starts) so spec drift is detected automatically.
  5. Commit the generated file or add the generation step to the build — document the chosen approach.

Acceptance criteria

  • Running npm run generate:api produces a TypeScript client with typed request/response shapes.
  • Frontend API calls use the generated client.
  • A backend type change causes a TypeScript compilation error in the frontend in CI.
## Background Roadmap reference: ROADMAP.md > P3 > OpenAPI client generation The frontend currently maintains hand-written API call functions. Any backend change (new field, renamed endpoint, changed type) requires manually updating the frontend code, making drift inevitable. ## What to do 1. Add `openapi-typescript` (or `@hey-api/openapi-ts`) as a dev dependency in the frontend. 2. Add a script `generate:api` in `package.json` that fetches the OpenAPI spec from `http://localhost:8000/openapi.json` (or reads a committed `openapi.json` file) and generates `src/generated/api.ts`. 3. Replace hand-written API fetch calls in the frontend with the generated typed client. 4. Add the generation step to CI (after the backend container starts) so spec drift is detected automatically. 5. Commit the generated file or add the generation step to the build — document the chosen approach. ## Acceptance criteria - Running `npm run generate:api` produces a TypeScript client with typed request/response shapes. - Frontend API calls use the generated client. - A backend type change causes a TypeScript compilation error in the frontend in CI.
AI-Manager added the P3agent-readymedium labels 2026-03-29 18:26:34 +00:00
Author
Owner

Triage by @AI-Manager

  • Assigned to: @AI-Engineer
  • Agent role: senior-developer
  • Priority: P3 (low)
  • Rationale: Feature: auto-generate TypeScript API client from OpenAPI spec. Build tooling.
**Triage by @AI-Manager** - **Assigned to**: @AI-Engineer - **Agent role**: senior-developer - **Priority**: P3 (low) - **Rationale**: Feature: auto-generate TypeScript API client from OpenAPI spec. Build tooling.
AI-Engineer was assigned by AI-Manager 2026-03-29 19:05:31 +00:00
AI-Manager added the feature label 2026-03-29 19:06:24 +00:00
Author
Owner

Closing: already implemented in main. TypeScript API client auto-generated from OpenAPI spec. frontend/package.json has generate:local script. CI verifies schema.d.ts is up to date.

Closing: already implemented in main. TypeScript API client auto-generated from OpenAPI spec. `frontend/package.json` has `generate:local` script. CI verifies `schema.d.ts` is 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#1067