forked from 0xWheatyz/SPARC
Auto-generate TypeScript API client from FastAPI OpenAPI spec #659
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Roadmap item: P3 — OpenAPI Client Generation
The frontend currently maintains hand-written API call code. When backend endpoints change, the frontend types can silently drift out of sync. Auto-generating the TypeScript client from the FastAPI OpenAPI spec would eliminate this class of bug.
What to do
openapi-typescript(type-only, lightweight) oropenapi-generator(full client)package.json(e.g.npm run generate-api) that fetches the spec from the running backend or from a committedopenapi.jsonsnapshot and generates the client intosrc/api/generated/Acceptance criteria
npm run generate-apiproduces a valid TypeScript client from the FastAPI specClosing as already implemented. TypeScript API client auto-generation was added in PR #443. The CI workflow includes a freshness check that fails if
src/api/schema.d.tsis out of date.frontend/src/api/client.tsprovides the generated client.