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

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

Context

Frontend API types are maintained by hand and drift from the backend schema over time. Auto-generating the client from the FastAPI OpenAPI spec would eliminate this drift.

What to do

  • Add a code generation step using openapi-typescript or @hey-api/openapi-ts (or equivalent).
  • Generate the TypeScript client into frontend/src/api/ (or similar).
  • Add a generate:api script to package.json that fetches the spec from the running backend and regenerates the client.
  • Integrate the generation step into CI so a PR that changes the backend schema but not the generated client fails.

Acceptance criteria

  • Running npm run generate:api produces an up-to-date TypeScript client.
  • The generated client is committed and used in place of hand-written fetch calls.
  • CI fails when backend schema changes are not reflected in the generated client.
  • No hand-maintained type definitions for API shapes remain.

References

Roadmap item: P3 — OpenAPI client generation.

## Context Frontend API types are maintained by hand and drift from the backend schema over time. Auto-generating the client from the FastAPI OpenAPI spec would eliminate this drift. ## What to do - Add a code generation step using `openapi-typescript` or `@hey-api/openapi-ts` (or equivalent). - Generate the TypeScript client into `frontend/src/api/` (or similar). - Add a `generate:api` script to `package.json` that fetches the spec from the running backend and regenerates the client. - Integrate the generation step into CI so a PR that changes the backend schema but not the generated client fails. ## Acceptance criteria - [ ] Running `npm run generate:api` produces an up-to-date TypeScript client. - [ ] The generated client is committed and used in place of hand-written fetch calls. - [ ] CI fails when backend schema changes are not reflected in the generated client. - [ ] No hand-maintained type definitions for API shapes remain. ## References Roadmap item: P3 — OpenAPI client generation.
AI-Manager added the P3agent-readymediumfeature labels 2026-03-28 13:24:54 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-28 14:03:14 +00:00
Author
Owner

Triage: Already implemented

This issue has been fully addressed in the fork main branch.

Verification:

  • frontend/src/api/schema.d.ts contains the auto-generated TypeScript API client from the FastAPI OpenAPI spec.
  • CI workflow verifies the generated types are up to date (npm run generate:local + git diff check in test.yaml lines 43-51).
  • Merged via PR #63 (feature/openapi-client-gen) and PR #443 (feature/426-generate-ts-api-client).

Closing.

## Triage: Already implemented This issue has been fully addressed in the fork main branch. **Verification:** - `frontend/src/api/schema.d.ts` contains the auto-generated TypeScript API client from the FastAPI OpenAPI spec. - CI workflow verifies the generated types are up to date (`npm run generate:local` + git diff check in `test.yaml` lines 43-51). - Merged via PR #63 (feature/openapi-client-gen) and PR #443 (feature/426-generate-ts-api-client). Closing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#682