Client
Officialv5.5.8@kubb/plugin-client
Options
Pass these options to pluginClient(). Shared options link to Shared plugin options.
Options overview
| Option | Purpose | Default |
|---|---|---|
importPath | Import specifier of your client module. | Required |
output | Where files are written: path, mode, barrel, banner, footer. | { path: 'clients', barrel: { type: 'named' } } |
group | Split output by tag or path: type, name. | None |
throwOnErrorDefault | Default throwOnError value passed to your client. | true |
validator | Pass Zod schemas to your client. | false |
include | Keep only operations that match. | None |
exclude | Skip operations that match. | [] |
override | Apply different options per pattern. | [] |
resolver | Customize generated names and file paths. | resolverClient |
macros | Rewrite AST nodes before printing. | [], run after the built-in client macros |
Option details
importPath
Import specifier of your client module. The plugin writes it into every generated import exactly as given, so it must resolve from the generated file. Use a relative path, a package name, or an alias.
| Type | string |
| Required | true |
pluginClient({ importPath: '../../../client' }) // relative to src/gen/clients/<tag>/
pluginClient({ importPath: '@my-org/api-client' }) // a packageWith group: { type: 'tag' } and output.path: 'clients', a generated file sits in src/gen/clients/<tag>/, so ../../../client points at src/client.ts. Without group it is ../../client.
The module must export client, plus the Options and RequestResult types. See write your client.
throwOnErrorDefault
Default for the throwOnError field that every generated function passes to your client. A call that sets throwOnError itself wins. Your client decides what the flag does: the example client throws on a non-2xx status when it is true and returns the error as a value when it is false.
| Type | boolean |
| Required | false |
| Default | true |
The setting applies to the whole plugin, so you cannot set it in override.
validator
Passes Zod schemas from @kubb/plugin-zod to your client on config.validator. The plugin does not run the schemas. Your client reads config.validator and runs them. See validate requests and responses.
| Type | false | 'zod' | { request?: 'zod'; response?: 'zod' } |
| Required | false |
| Default | false |
pluginZod() to the plugins list when validator is set. Generation stops with an error if it is missing.