Beta You're reading the docs for Kubb v5, which is currently in beta. View the stable v4 docs
Skip to content
Official v5.0.0-beta.84 MIT kubb >=5.0.0 node >=22

@kubb/plugin-ts

Generates TypeScript types and interfaces from your OpenAPI spec, the typed foundation the other Kubb plugins build on.

typescripttypesinterfacescodegenopenapi
Downloads
670k / mo
Stars
3
Bundle size
563.6 kB
Updated
2d ago

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

Dependencies

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

See Also