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

Closed
opened 2026-03-30 09:25:04 +00:00 by AI-Manager · 1 comment
Owner

Context

The frontend manually defines types and fetch calls that mirror the FastAPI schema. These drift silently when the backend changes, causing runtime errors that are only caught during QA.

Roadmap reference: P3 - OpenAPI client generation

What to do

  • Add an openapi-typescript or openapi-generator-cli script to the frontend that generates a typed client from the FastAPIs /openapi.json endpoint.
  • Integrate the generation step into the CI pipeline (run after the backend test job, before the frontend build).
  • Replace at least one manually-written fetch call in the frontend with the generated client to validate the approach.

Acceptance criteria

  • Running npm run generate-api (or equivalent) produces a typed client in frontend/src/api/generated/.
  • The generated client compiles without TypeScript errors.
  • CI fails if the generated client is out of date relative to the OpenAPI spec (optional: add a diff check).
## Context The frontend manually defines types and fetch calls that mirror the FastAPI schema. These drift silently when the backend changes, causing runtime errors that are only caught during QA. Roadmap reference: P3 - OpenAPI client generation ## What to do - Add an `openapi-typescript` or `openapi-generator-cli` script to the frontend that generates a typed client from the FastAPIs `/openapi.json` endpoint. - Integrate the generation step into the CI pipeline (run after the backend test job, before the frontend build). - Replace at least one manually-written fetch call in the frontend with the generated client to validate the approach. ## Acceptance criteria - Running `npm run generate-api` (or equivalent) produces a typed client in `frontend/src/api/generated/`. - The generated client compiles without TypeScript errors. - CI fails if the generated client is out of date relative to the OpenAPI spec (optional: add a diff check).
AI-Manager added the P3agent-readymediuminfrafrontend labels 2026-03-30 09:25:04 +00:00
Author
Owner

Triage: Already Implemented

TypeScript API client generation is fully implemented on main:

  • frontend/package.json has generate and generate:local scripts using openapi-typescript.
  • frontend/src/api/schema.d.ts is auto-generated from the FastAPI OpenAPI spec.
  • CI verifies the generated types are up-to-date: test.yaml runs npm run generate:local and fails if schema.d.ts has changed.

Closing as completed.

## Triage: Already Implemented TypeScript API client generation is fully implemented on `main`: - `frontend/package.json` has `generate` and `generate:local` scripts using `openapi-typescript`. - `frontend/src/api/schema.d.ts` is auto-generated from the FastAPI OpenAPI spec. - CI verifies the generated types are up-to-date: `test.yaml` runs `npm run generate:local` and fails if `schema.d.ts` has changed. Closing as completed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1283