@kubb/plugin-ts
@kubb/plugin-ts turns your OpenAPI schemas into TypeScript types and interfaces. Most other Kubb plugins build on it. Clients, query hooks, mocks, and validators reuse the names it generates. That way every request, response, parameter, and enum is checked at compile time.
Installation
shell
bun add -d @kubb/plugin-ts@betashell
pnpm add -D @kubb/plugin-ts@betashell
npm install --save-dev @kubb/plugin-ts@betashell
yarn add -D @kubb/plugin-ts@betaDependencies
@kubb/plugin-ts has no plugin dependencies. It reads the OpenAPI spec through @kubb/adapter-oas and produces the type names every other plugin reuses, so add it whenever a client, query, mock, or validator plugin needs typed output.
Example
typescript
import { } from 'kubb'
import { } from '@kubb/plugin-ts'
export default ({
: { : './petStore.yaml' },
: { : './src/gen' },
: [
({
: { : './types' },
: [{ : 'tag', : 'store' }],
: { : 'tag' },
: { : 'asConst' },
: 'questionTokenAndUndefined',
}),
],
})