Skip to content
Officialv5.5.10MITkubb >=5.0.0node >=22

@kubb/plugin-axios

Generates a type-safe axios client from your OpenAPI spec, one async function per operation, so each call stays in sync with the API.

api-clientaxioshttp-clientcodegenopenapivalidator
Stijn Van Hulle

Stijn Van Hulle

@stijnvanhulle

Downloads
26.8K/ mo
Stars
8
Bundle size
453.3 kB
Updated
39m ago

Generate typed API calls with Axios.

  • One async function per OpenAPI operation.
  • Grouped request parameters and status-keyed results.

Installation

bun add -d @kubb/plugin-axios

Or run kubb add plugin-axios to install the version the Kubb registry pins and add pluginAxios() to kubb.config.ts.

Dependencies

  • Add pluginTs or pluginZod with inferred: true for operation types. pluginTs takes precedence.
  • Add pluginZod for validation.
  • Install Axios v1 or higher in the consuming app.

Example

kubb.config.ts
import { defineConfig } from 'kubb/config'
import { pluginTs } from '@kubb/plugin-ts'
import { pluginAxios } from '@kubb/plugin-axios'

export default defineConfig({
  input: './petStore.yaml',
  output: { path: './src/gen' },
  plugins: [
    pluginTs(),
    pluginAxios({ baseURL: 'https://petstore.swagger.io/v2' }),
  ],
})

See also