- Downloads
- 278.2K/ mo
- Stars
- 8
- Bundle size
- 170.2 kB
- Updated
- 3d ago
Generate typed MSW handlers from OpenAPI.
- Supply response data in tests.
- Generate mock responses with Faker.
Installation
bun add -d @kubb/plugin-mswpnpm add -D @kubb/plugin-mswnpm install --save-dev @kubb/plugin-mswyarn add -D @kubb/plugin-mswDependencies
- Add
pluginTs. - Add
pluginFakerforparser: 'faker'. The default'data'parser does not need it. - Generated handlers require MSW v2 or higher.
Example
kubb.config.ts
import { defineConfig } from 'kubb'
import { pluginTs } from '@kubb/plugin-ts'
import { pluginMsw } from '@kubb/plugin-msw'
export default defineConfig({
input: './petStore.yaml',
output: { path: './src/gen' },
plugins: [
pluginTs(),
pluginMsw({ output: { path: 'handlers', mode: 'directory' }, handlers: true }),
],
})