Migration: @kubb/adapter-oas
Part of the v4 → v5 migration guide. See the full option reference in @kubb/adapter-oas.
@kubb/plugin-oas is gone. When you import defineConfig from kubb, the OpenAPI adapter is applied for you, so most projects never name it. Set adapter: adapterOas({ ... }) only when you want to change its options.
v4 repeated the same schema-level options on every plugin. In v5 they live on adapterOas and apply once across all plugins. Remove them from each plugin and set them on the adapter.
| Option | Removed from | v5 location |
|---|---|---|
dateType | plugin-ts, plugin-faker, plugin-zod | adapterOas({ dateType }) |
integerType | plugin-ts, plugin-zod, plugin-faker | adapterOas({ integerType }) |
unknownType | plugin-ts, plugin-zod, plugin-faker | adapterOas({ unknownType }) |
emptySchemaType | plugin-ts, plugin-zod, plugin-faker | adapterOas({ emptySchemaType }) |
enumSuffix | plugin-ts | adapterOas({ enumSuffix }) |
contentType | plugin-ts, plugin-msw | adapterOas({ contentType }) |
IMPORTANT
The default integerType changed from 'number' to 'bigint'. OpenAPI int64 fields now map to bigint. Set integerType: 'number' on adapterOas to keep the old output.
import { defineConfig } from '@kubb/core'
import { pluginTs } from '@kubb/plugin-ts'
import { pluginZod } from '@kubb/plugin-zod'
import { pluginFaker } from '@kubb/plugin-faker'
export default defineConfig({
input: { path: './petstore.yaml' },
output: { path: './src/gen' },
plugins: [
pluginTs({
dateType: 'date',
integerType: 'number',
unknownType: 'unknown',
emptySchemaType: 'unknown',
enumSuffix: 'enum',
}),
pluginZod({
dateType: 'date',
integerType: 'number',
unknownType: 'unknown',
}),
pluginFaker({
dateType: 'date',
integerType: 'number',
unknownType: 'unknown',
}),
],
})import { } from 'kubb'
import { } from '@kubb/adapter-oas'
import { } from '@kubb/plugin-ts'
import { } from '@kubb/plugin-zod'
import { } from '@kubb/plugin-faker'
export default ({
: { : './petstore.yaml' },
: { : './src/gen' },
: ({
: 'date',
: 'number',
: 'unknown',
: 'unknown',
: 'enum',
}),
: [(), (), ()],
})pluginOas() no longer belongs in plugins. Its validate, discriminator, and contentType options move to the same adapter key, and the old serverIndex and serverVariables become a single server: { index, variables } object. See @kubb/plugin-oas removed on the main guide. validate still defaults to true.
The discriminator values are also renamed. Use 'preserve' in place of 'strict', and 'propagate' in place of 'inherit'. The default is 'preserve', so drop the option unless you want the old 'inherit' behavior.
import { defineConfig } from '@kubb/core'
import { pluginOas } from '@kubb/plugin-oas'
import { pluginTs } from '@kubb/plugin-ts'
export default defineConfig({
input: { path: './petstore.yaml' },
output: { path: './src/gen' },
plugins: [
pluginOas({
validate: true,
serverIndex: 0,
serverVariables: { env: 'prod' },
discriminator: 'inherit',
}),
pluginTs(),
],
})import { } from 'kubb'
import { } from '@kubb/adapter-oas'
import { } from '@kubb/plugin-ts'
export default ({
: { : './petstore.yaml' },
: { : './src/gen' },
: ({
: true,
: { : 0, : { : 'prod' } },
: 'propagate',
}),
: [()],
})New enums option
v5 adds enums to adapterOas to control where inline enums live. The default 'inline' keeps each enum on the property that declares it, which matches v4 output, so you can ignore this option unless you want the new behavior. Set enums: 'root' to lift every inline enum to a reusable top-level schema named after its context, such as PetStatusEnum, and reference it everywhere it appears.
import { } from 'kubb'
import { } from '@kubb/adapter-oas'
import { } from '@kubb/plugin-ts'
export default ({
: { : './petstore.yaml' },
: { : './src/gen' },
: ({
: 'root',
}),
: [()],
})