forked from 0xWheatyz/SPARC
Auto-generate TypeScript API client from FastAPI OpenAPI spec #224
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
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
openapi-typescript-codegen(ororval/hey-api) as a dev dependency in the frontend.generate:apinpm script that fetches the OpenAPI spec from the running backend and generates a typed client intosrc/api/generated/.Acceptance criteria
npm run generate:apiproduces a typed TypeScript client insrc/api/generated/./analyzeand/jobsendpoints.This issue has already been resolved in the current codebase.
frontend/package.jsonincludesopenapi-typescript(^7.0.0) as a dev dependency with two npm scripts:generate: fetches the OpenAPI spec from the running API and generatessrc/api/schema.d.tsgenerate:local: generates from the committedsrc/api/openapi.jsonfileThe OpenAPI spec is also committed at
frontend/src/api/openapi.json.Closing as already implemented.