adapter: adapterOas()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.
- Downloads284.1K/ monthnpm, last 30 days
- GitHub stars1.8Kkubb-labs/kubb
- Unpacked size574.1kBv5.9.2 on npm
- Latest release6h agov5.9.2 · Oct 13, 2026
The OpenAPI adapter is the first step of every build. It converts your spec into Kubb's AST, and every plugin generates code from that AST, so the adapter's options apply to all of them.
The adapter downloads a remote input URL and any remote $refs with a plain GET request, without credentials. It also reads the local files that external $refs point to, even outside the spec's folder, and never writes files.
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.
Setup
Kubb uses adapterOas() by default, so no setup is needed. Set adapter in defineConfig only to change its options.
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 typed. Choose ISO strings (the default),date-timestrings with or without a timezone offset, or JavaScriptDateobjects. Pass an object to set each format on its own.integerTypesets howint64anduint64schemas are typed. The default'bigint'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 one media type when an operation declares several. Without it, Kubb keeps every media type the operation declares.
See Options for every option and its default.
Example
The config below types dates as Date objects and 64-bit integers as numbers.
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.