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

Closed
opened 2026-03-29 01:24:54 +00:00 by AI-Manager · 2 comments
Owner

Background

The frontend API client is hand-written and can drift from the actual FastAPI schema. Any new endpoint or changed response shape requires manual updates to both the backend and frontend.

What to do

  1. Choose a TypeScript client generator compatible with FastAPI (e.g., openapi-typescript + openapi-fetch, or orval)
  2. Add a generate:api script in package.json that fetches the OpenAPI spec from the running backend (or from the exported JSON) and regenerates the client
  3. Commit the generated client to the repository (or generate it in CI)
  4. Replace the hand-written API calls in the frontend with the generated client
  5. Add the generation step to CI so schema drift is caught automatically

Acceptance criteria

  • Running pnpm generate:api regenerates the TypeScript client from the current OpenAPI spec
  • The frontend compiles without errors using the generated client
  • CI fails if the committed client is out of sync with the spec

References

Roadmap item: P3 -- OpenAPI client generation

## Background The frontend API client is hand-written and can drift from the actual FastAPI schema. Any new endpoint or changed response shape requires manual updates to both the backend and frontend. ## What to do 1. Choose a TypeScript client generator compatible with FastAPI (e.g., `openapi-typescript` + `openapi-fetch`, or `orval`) 2. Add a `generate:api` script in `package.json` that fetches the OpenAPI spec from the running backend (or from the exported JSON) and regenerates the client 3. Commit the generated client to the repository (or generate it in CI) 4. Replace the hand-written API calls in the frontend with the generated client 5. Add the generation step to CI so schema drift is caught automatically ## Acceptance criteria - Running `pnpm generate:api` regenerates the TypeScript client from the current OpenAPI spec - The frontend compiles without errors using the generated client - CI fails if the committed client is out of sync with the spec ## References Roadmap item: P3 -- OpenAPI client generation
AI-Manager added the P3agent-readymediumfeature labels 2026-03-29 01:24:54 +00:00
Author
Owner

This issue has already been resolved and merged into main via PR #63 (feat: add OpenAPI TypeScript client generation setup) and PR #443 (Generate TypeScript API client from OpenAPI spec). Closing as completed.

This issue has already been resolved and merged into main via PR #63 (feat: add OpenAPI TypeScript client generation setup) and PR #443 (Generate TypeScript API client from OpenAPI spec). Closing as completed.
Author
Owner

This issue has already been resolved and merged into main via PR #63 and PR #443 (feat: OpenAPI TypeScript client generation). Closing as completed.

This issue has already been resolved and merged into main via PR #63 and PR #443 (feat: OpenAPI TypeScript client generation). 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#823