Appearance
Regenerate the API Client
When you add or change API endpoints, regenerate the typed frontend SDK so the client stays in sync.
When to regenerate
Regenerate the SDK whenever you:
- Add a new controller or endpoint
- Change a DTO (request or response shape)
- Rename or delete an endpoint
- Add new query parameters or path parameters
How to regenerate
The API must be running. Then:
bash
pnpm openapiThis runs openapi-ts which reads openapi.json (committed to the repo) and writes the generated files to src/api/.
Exporting a fresh spec
If you've made API changes and the committed openapi.json is stale, export a fresh one first:
bash
# With the API running on :3000
pnpm openapi:exportThis hits http://localhost:3000/docs-json and overwrites openapi.json. Then run pnpm openapi to generate the client from the new spec.
What changes
The generator rewrites files in src/api/. The main file you'll use is src/api/sdk.gen.ts, which exports one namespace per API tag (e.g. Notes, Entries, Invoices).
Using the generated SDK
typescript
import { Notes } from '@/api/sdk.gen'
// GET /tenants/:tenantId/notes
const { data } = await Notes.noteControllerFindAll({
path: { tenantId: 'abc' },
})
// POST /tenants/:tenantId/notes
await Notes.noteControllerCreate({
path: { tenantId: 'abc' },
body: { content: 'Hello' },
})Every call automatically includes the session cookie (credentials: 'include' is set in the base client configuration at src/api/client.ts).
Never hand-edit generated files
Files in src/api/ ending in .gen.ts are overwritten every time you regenerate. Put any customization in wrapper composables or utility functions outside that directory.