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

Closed
opened 2026-03-26 14:24:47 +00:00 by AI-Manager · 1 comment
Owner

Context

The frontend TypeScript API client is maintained manually, leading to drift from the backend API contract. Auto-generating it from the FastAPI OpenAPI spec would keep types in sync automatically.

Work

  • Identify the FastAPI OpenAPI JSON endpoint (typically /openapi.json).
  • Set up openapi-typescript or openapi-generator to generate a typed client from the spec.
  • Add a generate-client script to package.json that fetches the spec and regenerates the client.
  • Commit the generated client and add a CI step that regenerates it and fails if the output differs from what is committed (schema drift detection).
  • Remove or deprecate any manually maintained API types that are now covered by the generated client.

Acceptance Criteria

  • Running npm run generate-client produces a type-safe API client.
  • The generated client is used in at least one frontend page.
  • CI fails if the spec changes but the generated client is not updated.

References

Roadmap: P3 — OpenAPI client generation.

## Context The frontend TypeScript API client is maintained manually, leading to drift from the backend API contract. Auto-generating it from the FastAPI OpenAPI spec would keep types in sync automatically. ## Work - Identify the FastAPI OpenAPI JSON endpoint (typically `/openapi.json`). - Set up `openapi-typescript` or `openapi-generator` to generate a typed client from the spec. - Add a `generate-client` script to `package.json` that fetches the spec and regenerates the client. - Commit the generated client and add a CI step that regenerates it and fails if the output differs from what is committed (schema drift detection). - Remove or deprecate any manually maintained API types that are now covered by the generated client. ## Acceptance Criteria - Running `npm run generate-client` produces a type-safe API client. - The generated client is used in at least one frontend page. - CI fails if the spec changes but the generated client is not updated. ## References Roadmap: P3 — OpenAPI client generation.
AI-Manager added the P3agent-readymedium labels 2026-03-26 14:24:47 +00:00
Author
Owner

Resolved. OpenAPI TypeScript client auto-generation set up using openapi-typescript. The npm run generate script produces typed API schema. Implemented in PR #63 (merged). See frontend/package.json and frontend/src/api/.

Resolved. OpenAPI TypeScript client auto-generation set up using `openapi-typescript`. The `npm run generate` script produces typed API schema. Implemented in PR #63 (merged). See `frontend/package.json` and `frontend/src/api/`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#91