Adapter
adapter: adapterOas()Officialv5.8.3kubb >=5.8.0node >=22
OpenAPI
@kubb/adapter-oas
Reads an OpenAPI 2.0, 3.0, or 3.1 spec and converts every schema and operation into the AST that Kubb plugins generate from.
kubb add adapter-oas
openapiswaggerapi-specparserconverter
- Downloads284.1K/ monthnpm, last 30 days
- GitHub stars1.8Kkubb-labs/kubb
- Unpacked size579.9kBv5.8.3 on npm
- Latest release2h agov5.8.3 · Oct 13, 2026
The OpenAPI adapter reads an OpenAPI 2.0, 3.0, or 3.1 document and converts every schema and operation into Kubb's AST. Every plugin in the build generates code from that AST.
Kubb uses adapterOas() by default. Set it on defineConfig.adapter only to change its options. The options apply to every plugin in the build.
Installation
bun add -d @kubb/adapter-oaspnpm add -D @kubb/adapter-oasnpm install --save-dev @kubb/adapter-oasyarn add -D @kubb/adapter-oasOr run kubb add adapter-oas to install the version the Kubb registry pins and add adapterOas() to kubb.config.ts.
Options worth knowing
validatechecks the spec before parsing and reports each problem as a warning. Turn it off to speed up a large spec. Runkubb validateto list every error.dateTypesets howdate-time,date, andtimeschemas are represented: ISO strings (the default), strings with or without a timezone offset, or JavaScriptDateobjects. Pass an object to set each format on its own.integerTypedefaults to'bigint', which is exact for 64-bit IDs but does not surviveJSON.stringify. Choose'number'for most JSON APIs.unknownTypeandemptySchemaTypeset the type for schemas Kubb cannot infer and for empty schemas ({}).discriminator: 'propagate'writes the discriminator's literal value into each child schema, so each branch is typed precisely.enums: 'root'lifts inline enums to reusable top-level schemas, named withenumSuffix(PetStatusEnum).serverpicks the entry in the spec'sserversarray that becomes the base URL and fills in its variables. It does not change where a generated client sends requests. Use the client plugin's ownbaseURLfor that.contentTypepicks the media type when an operation defines several. Without it, Kubb uses the first JSON media type.
Example
kubb.config.ts
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({ dateType: 'date', integerType: 'number' }),
plugins: [pluginTs()],
})Dependencies
No extension dependencies.