@kubb/adapter-oas
The OpenAPI adapter sits between your spec and every Kubb plugin. It reads the spec from input, whether that is a file, a URL, inline content, or a parsed object, validates it, and converts each schema and operation into Kubb's universal AST that downstream plugins consume.
Configure it once on defineConfig. Its choices for date representation, integer width, and server URL apply to every plugin in the build.
See Options for the full configuration reference.
Installation
bun add -d @kubb/adapter-oas@betapnpm add -D @kubb/adapter-oas@betanpm install --save-dev @kubb/adapter-oas@betayarn add -D @kubb/adapter-oas@betaDependencies
@kubb/adapter-oas has no plugin dependencies. It reads your OpenAPI spec and converts it into the AST that every Kubb plugin generates from, so plugins depend on it rather than the other way around.
Example
import { defineConfig } from 'kubb'
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',
enums: 'root',
dateType: 'date',
integerType: 'number',
unknownType: 'unknown',
emptySchemaType: 'unknown',
enumSuffix: 'enum',
}),
plugins: [pluginTs()],
})