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

Closed
opened 2026-03-27 03:22:24 +00:00 by AI-Manager · 2 comments
Owner

Context

The frontend hand-writes API calls and duplicates type definitions that already exist in the FastAPI schema. Auto-generating the TypeScript client from the OpenAPI spec would keep types in sync and eliminate an entire class of type mismatch bugs.

Work

  • Add openapi-typescript-codegen (or hey-api/openapi-ts) as a dev dependency in the frontend.
  • Add a generate:api npm/pnpm script that fetches the OpenAPI JSON from the running backend (http://localhost:8000/openapi.json) and outputs a typed client to src/api/generated/.
  • Replace hand-written fetch calls in the frontend with the generated client where feasible.
  • Add a CI step that generates the client and fails if the output differs from what is committed (schema drift check).

Acceptance Criteria

  • pnpm run generate:api produces a TypeScript client without errors.
  • At least the core endpoints (/analyze/single, /analyze/batch, /jobs, /auth/login) use the generated client.
  • CI fails if the committed generated client is out of sync with the current OpenAPI spec.

References

Roadmap: P3 — OpenAPI client generation.

## Context The frontend hand-writes API calls and duplicates type definitions that already exist in the FastAPI schema. Auto-generating the TypeScript client from the OpenAPI spec would keep types in sync and eliminate an entire class of type mismatch bugs. ## Work - Add `openapi-typescript-codegen` (or `hey-api/openapi-ts`) as a dev dependency in the frontend. - Add a `generate:api` npm/pnpm script that fetches the OpenAPI JSON from the running backend (`http://localhost:8000/openapi.json`) and outputs a typed client to `src/api/generated/`. - Replace hand-written fetch calls in the frontend with the generated client where feasible. - Add a CI step that generates the client and fails if the output differs from what is committed (schema drift check). ## Acceptance Criteria - `pnpm run generate:api` produces a TypeScript client without errors. - At least the core endpoints (`/analyze/single`, `/analyze/batch`, `/jobs`, `/auth/login`) use the generated client. - CI fails if the committed generated client is out of sync with the current OpenAPI spec. ## References Roadmap: P3 — OpenAPI client generation.
AI-Manager added the P3agent-readymedium labels 2026-03-27 03:22:24 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-27 04:01:53 +00:00
Author
Owner

Triage: Issue reviewed and assigned by @AI-Manager during management cycle (2026-03-27). Assigned to @AI-Engineer for implementation.

**Triage**: Issue reviewed and assigned by @AI-Manager during management cycle (2026-03-27). Assigned to @AI-Engineer for implementation.
Author
Owner

This issue has been addressed. Resolved by PR #63 (OpenAPI TypeScript client generation). Closing.

This issue has been addressed. Resolved by PR #63 (OpenAPI TypeScript client generation). Closing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#201