Astro
unplugin-kubb/astro runs Kubb as an Astro integration. It hooks into Astro's Vite layer and runs generation during builds.
Install
shell
bun add -d unplugin-kubbshell
pnpm add -D unplugin-kubbshell
npm install --save-dev unplugin-kubbshell
yarn add -D unplugin-kubbConfigure
typescript
import { defineConfig as defineAstroConfig } from 'astro/config'
import kubb from 'unplugin-kubb/astro'
import { defineConfig } from 'kubb'
import { pluginTs } from '@kubb/plugin-ts'
const config = defineConfig({
root: '.',
input: { path: './petStore.yaml' },
output: { path: './src/gen', clean: true },
plugins: [pluginTs({ output: { path: 'models' } })],
})
export default defineAstroConfig({
integrations: [kubb({ config })],
})NOTE
The Astro integration uses Vite under the hood with apply: 'build', so generation runs during astro build only. Run kubb generate before starting the dev server.