@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
shell
bun add -d @kubb/adapter-oas@betashell
pnpm add -D @kubb/adapter-oas@betashell
npm install --save-dev @kubb/adapter-oas@betashell
yarn add -D @kubb/adapter-oas@betaDependencies
@kubb/adapter-oas has no plugin dependencies. Every other Kubb plugin depends on it, not the other way around.
Example
typescript
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()],
})