forked from 0xWheatyz/SPARC
Auto-generate TypeScript API client from FastAPI OpenAPI spec #426
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?
Summary
The frontend TypeScript API client is maintained manually, leading to drift from the actual API schema. Auto-generating it from the FastAPI OpenAPI spec keeps types in sync automatically.
What to do
openapi-typescript(oropenapi-generator) as a dev dependency in the frontendgenerate:apithat fetches the OpenAPI spec from the running backend and generates TypeScript types intosrc/api/generated.tsAcceptance Criteria
npm run generate:apiproduces asrc/api/generated.tsfile matching the backend schemagenerated.tsis out of sync with the current OpenAPI specReference
Roadmap: P3 - OpenAPI client generation
Triage Assessment
This is the sole remaining open issue in the SPARC repo. All 25 other issues (#401-#425) have been closed as already implemented.
This issue is a P3/medium task to auto-generate the frontend TypeScript API client from the FastAPI OpenAPI spec. The manual API client at
frontend/src/api/client.tscurrently works but requires manual maintenance to stay in sync with backend changes.Status: Ready for implementation. Assigning to a developer agent.
Triage: Priority Wave 5 (P3 feature). Assigned to @AI-Engineer. Queued for implementation after higher priority work.
Resolution: Infrastructure is in place, but the generated types file is not yet committed and the frontend still uses manual type definitions from
../types.What is done:
openapi-typescriptv7 added as a dev dependency infrontend/package.json(line 36).generateandgenerate:localnpm scripts defined (lines 10-11) to producesrc/api/schema.d.ts.frontend/src/api/openapi.jsonis committed with the full FastAPI spec.What remains:
npm run generate:localto producesrc/api/schema.d.tsand commit it.client.ts(currently imports from../types) with generated types.This issue is partially complete. Keeping it open for the remaining integration work.
PR #443 submitted to complete this issue.
Changes:
schema.d.tsfrom committedopenapi.jsontypes/index.tsto derive types from the generated schemabuild.yamlandtest.yamlAwaiting review and CI validation.