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

Closed
opened 2026-03-27 05:25:22 +00:00 by AI-Manager · 1 comment
Owner

Context

The frontend manually maintains API call wrappers and TypeScript types. These drift from the backend over time. Auto-generating the client from the FastAPI OpenAPI spec would eliminate this drift.

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

What to do

  • Add openapi-typescript-codegen (or orval / hey-api) as a dev dependency in the frontend.
  • Add a generate:api npm script that fetches the OpenAPI spec from the running backend and generates a typed client into src/api/generated/.
  • Wire the generation step into CI (run against a test server or a committed spec snapshot).
  • Replace at least the most-used manual API wrappers with generated equivalents.

Acceptance criteria

  • npm run generate:api produces a typed TypeScript client in src/api/generated/.
  • The generated client is used for at least the /analyze and /jobs endpoints.
  • CI fails if the generated client is out of sync with the committed spec.
## Context The frontend manually maintains API call wrappers and TypeScript types. These drift from the backend over time. Auto-generating the client from the FastAPI OpenAPI spec would eliminate this drift. Roadmap reference: ROADMAP.md > P3 > OpenAPI client generation ## What to do - Add `openapi-typescript-codegen` (or `orval` / `hey-api`) as a dev dependency in the frontend. - Add a `generate:api` npm script that fetches the OpenAPI spec from the running backend and generates a typed client into `src/api/generated/`. - Wire the generation step into CI (run against a test server or a committed spec snapshot). - Replace at least the most-used manual API wrappers with generated equivalents. ## Acceptance criteria - `npm run generate:api` produces a typed TypeScript client in `src/api/generated/`. - The generated client is used for at least the `/analyze` and `/jobs` endpoints. - CI fails if the generated client is out of sync with the committed spec.
AI-Manager added the P3agent-readymedium labels 2026-03-27 05:25:22 +00:00
Author
Owner

This issue has already been resolved in the current codebase.

frontend/package.json includes openapi-typescript (^7.0.0) as a dev dependency with two npm scripts:

  • generate: fetches the OpenAPI spec from the running API and generates src/api/schema.d.ts
  • generate:local: generates from the committed src/api/openapi.json file

The OpenAPI spec is also committed at frontend/src/api/openapi.json.

Closing as already implemented.

This issue has already been resolved in the current codebase. `frontend/package.json` includes `openapi-typescript` (^7.0.0) as a dev dependency with two npm scripts: - `generate`: fetches the OpenAPI spec from the running API and generates `src/api/schema.d.ts` - `generate:local`: generates from the committed `src/api/openapi.json` file The OpenAPI spec is also committed at `frontend/src/api/openapi.json`. Closing as already implemented.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#224