Are you an LLM? You can read better optimized documentation at /sdk/generating.md for this page in Markdown format
Generating the SDK
The SDK is auto-generated from the API's OpenAPI specification using Kubb.
When to Regenerate
Regenerate the SDK after:
- Adding new API endpoints
- Modifying request/response types
- Changing authentication requirements
- Updating API routes
Prerequisites
Updated OpenAPI spec from the API:
bashcd api pnpm generate:openapiThe spec file at
api/swagger.json
Generation Steps
1. Update API Spec
First, ensure the API's OpenAPI spec is current:
bash
cd api
pnpm generate:openapiThis updates api/swagger.json.
2. Generate SDK
bash
cd sdk
pnpm generateThis reads api/swagger.json and generates:
- Client methods in
src/client/ - Types in
src/types/ - Axios configuration in
src/axios/
3. Build
bash
pnpm build4. Verify
Check that exports work:
bash
pnpm lint:fixKubb Configuration
The generator is configured in kubb.config.ts:
typescript
import { defineConfig } from "@kubb/core"
import createSwagger from "@kubb/swagger"
import createSwaggerTs from "@kubb/swagger-ts"
import createSwaggerClient from "@kubb/swagger-client"
export default defineConfig({
input: {
path: "../api/swagger.json",
},
output: {
path: "./src",
},
plugins: [
createSwagger(),
createSwaggerTs(),
createSwaggerClient({
client: "axios",
}),
],
})Troubleshooting
Type Errors After Generation
Run lint fix:
bash
pnpm lint:fixMissing Endpoints
Ensure the API controller has the @Tags decorator and re-run:
bash
cd api && pnpm generate:openapi
cd ../sdk && pnpm generateBuild Failures
Clear generated files and regenerate:
bash
rm -rf src/client src/types src/axios
pnpm generate
pnpm buildCI/CD
The SDK is automatically published to Buildkite when:
- Changes are pushed to the SDK directory
- The
api/swagger.jsonis updated
Version bumping is handled by the CI pipeline based on commit messages.