Loading...
Loading...
Generate TypeScript clients from OpenAPI specs using @hey-api/openapi-ts — type-safe API clients. Use when generating TypeScript clients from OpenAPI specifications for frontend or API consumers.
npx skill4agent add blockmatic/basilic-skills openapi-ts-v0@hey-api/openapi-ts@hey-api/openapi-tscreateClientopenapi-ts.config.tsresponse.erroroutput.format: 'prettier'types.enums: 'typescript'schemas.type: 'zod'// openapi-ts.config.ts
import { defineConfig } from '@hey-api/openapi-ts'
export default defineConfig({
input: './openapi.json',
output: {
path: './src/gen',
format: 'prettier',
},
types: {
enums: 'typescript',
},
})import { createClient } from './gen/client'
const client = createClient({
baseUrl: 'https://api.example.com',
})
const response = await client.GET('/users/{id}', {
params: { path: { id: '123' } },
})
if (response.error) {
// Handle typed error
return
}
// response.data is typed from OpenAPI spec