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

Closed
opened 2026-03-30 18:24:31 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P3 -- OpenAPI client generation

The frontend manually defines API types that can drift from the backend schema. Auto-generating the TypeScript client from FastAPI's OpenAPI spec would keep types in sync automatically.

What to do

  • Add an openapi-typescript (or openapi-generator) code generation step to the frontend build or a dedicated script.
  • Generate the client into a src/api/generated/ directory.
  • Replace manual fetch calls and type definitions with the generated client where practical.
  • Add the generation step to CI so a schema drift is caught on PRs.

Acceptance criteria

  • Running the generation script produces a TypeScript client that matches the current FastAPI schema.
  • At least one existing API call in the frontend is migrated to use the generated client.
  • CI fails if the committed generated client is out of sync with the current spec.
## Context Roadmap item: P3 -- OpenAPI client generation The frontend manually defines API types that can drift from the backend schema. Auto-generating the TypeScript client from FastAPI's OpenAPI spec would keep types in sync automatically. ## What to do - Add an `openapi-typescript` (or `openapi-generator`) code generation step to the frontend build or a dedicated script. - Generate the client into a `src/api/generated/` directory. - Replace manual `fetch` calls and type definitions with the generated client where practical. - Add the generation step to CI so a schema drift is caught on PRs. ## Acceptance criteria - [ ] Running the generation script produces a TypeScript client that matches the current FastAPI schema. - [ ] At least one existing API call in the frontend is migrated to use the generated client. - [ ] CI fails if the committed generated client is out of sync with the current spec.
AI-Manager added the P3agent-readylargefeature labels 2026-03-30 18:24:31 +00:00
Author
Owner

Triage: Already resolved in main.

TypeScript API client auto-generation is fully set up:

  • openapi-typescript (v7) is a devDependency in frontend/package.json
  • npm run generate fetches live OpenAPI spec; npm run generate:local uses committed spec
  • Generated types live in frontend/src/api/schema.d.ts
  • CI (test.yaml) verifies generated types are up-to-date by running generate:local and checking for diffs
  • App types in frontend/src/types/index.ts derive from the generated schema

Closing as complete.

**Triage: Already resolved in main.** TypeScript API client auto-generation is fully set up: - `openapi-typescript` (v7) is a devDependency in `frontend/package.json` - `npm run generate` fetches live OpenAPI spec; `npm run generate:local` uses committed spec - Generated types live in `frontend/src/api/schema.d.ts` - CI (`test.yaml`) verifies generated types are up-to-date by running `generate:local` and checking for diffs - App types in `frontend/src/types/index.ts` derive from the generated schema 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#1419