- Downloads
- 469.3K/ mo
- Stars
- 8
- Bundle size
- 287.9 kB
- Updated
- 2h ago
Generate typed API calls for your own HTTP client.
- Grouped parameters:
path,query,headers, andbody. - Per-operation authentication requirements in a
securitylist. - Per-call
clientoverrides and your client'sRequestResultreturn type. - Optional Zod validation schemas passed to your client.
Use it for signed requests, a shared client, or an existing HTTP layer. Write your client to define the required exports. The generated code has no Fetch, Axios, or Kubb runtime dependency.
Installation
bun add -d @kubb/plugin-clientpnpm add -D @kubb/plugin-clientnpm install --save-dev @kubb/plugin-clientyarn add -D @kubb/plugin-clientOr run kubb add plugin-client to install the version the Kubb registry pins and add pluginClient() to kubb.config.ts.
Dependencies
Set importPath to your client module. No HTTP client package is required.
Example
import { defineConfig } from 'kubb/config'
import { pluginTs } from '@kubb/plugin-ts'
import { pluginClient } from '@kubb/plugin-client'
export default defineConfig({
input: './petStore.yaml',
output: { path: './src/gen' },
plugins: [
pluginTs(),
pluginClient({
output: { path: 'clients', mode: 'directory', barrel: { type: 'named' } },
group: { type: 'tag' },
// resolved from each generated file: src/gen/clients/<tag>/ to src/client.ts
importPath: '../../../client',
}),
],
})