Skip to content
Official v5.0.0 MIT kubb >=5.0.0 node >=22

@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, so one adapter feeds the whole build.

openapiswaggerapi-specparserconverter
Downloads
21k / mo
Stars
1.8k
Bundle size
577.7 kB
Updated
4d ago

@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
shell
pnpm add -D @kubb/adapter-oas
shell
npm install --save-dev @kubb/adapter-oas
shell
yarn add -D @kubb/adapter-oas

Dependencies

@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
()],
})

See also