Open Studio
Migration

Migration: @kubb/adapter-oas

Configuration changes for @kubb/adapter-oas when migrating from Kubb v4 to v5.

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.

Move schema options to the adapter ​

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.

OptionRemoved fromv5 location
dateTypeplugin-ts, plugin-faker, plugin-zodadapterOas({ dateType })
integerTypeplugin-ts, plugin-zod, plugin-fakeradapterOas({ integerType })
unknownTypeplugin-ts, plugin-zod, plugin-fakeradapterOas({ unknownType })
emptySchemaTypeplugin-ts, plugin-zod, plugin-fakeradapterOas({ emptySchemaType })
enumSuffixplugin-tsadapterOas({ enumSuffix })
contentTypeplugin-ts, plugin-zod, plugin-mswadapterOas({ 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.

typescript
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: './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',
    }),
  ],
})
typescript
import { defineConfig } from 'kubb/config'
import { adapterOas } from '@kubb/adapter-oas'
import { pluginTs } from '@kubb/plugin-ts'
import { pluginZod } from '@kubb/plugin-zod'
import { pluginFaker } from '@kubb/plugin-faker'

export default defineConfig({
  input: './petstore.yaml',
  output: { path: './src/gen' },
  adapter: adapterOas({
    dateType: 'date',
    integerType: 'number',
    unknownType: 'unknown',
    emptySchemaType: 'unknown',
    enumSuffix: 'enum',
  }),
  plugins: [pluginTs(), pluginZod(), pluginFaker()],
})

pluginOas options move to the adapter ​

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: 'strict' → 'preserve' and 'inherit' → 'propagate'. The default is 'preserve', so drop the option unless you want the old 'inherit' behavior.

typescript
import { defineConfig } from '@kubb/core'
import { pluginOas } from '@kubb/plugin-oas'
import { pluginTs } from '@kubb/plugin-ts'

export default defineConfig({
  input: './petstore.yaml',
  output: { path: './src/gen' },
  plugins: [
    pluginOas({
      validate: true,
      serverIndex: 0,
      serverVariables: { env: 'prod' },
      discriminator: 'inherit',
    }),
    pluginTs(),
  ],
})
typescript
import { defineConfig } from 'kubb/config'
import { adapterOas } from '@kubb/adapter-oas'
import { pluginTs } from '@kubb/plugin-ts'

export default defineConfig({
  input: './petstore.yaml',
  output: { path: './src/gen' },
  adapter: adapterOas({
    validate: true,
    server: { index: 0, variables: { env: 'prod' } },
    discriminator: 'propagate',
  }),
  plugins: [pluginTs()],
})