- Downloads
- 286.8K/ mo
- Stars
- 8
- Bundle size
- 174.8 kB
- Updated
- 36m 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-mswOr run kubb add plugin-msw to install the version the Kubb registry pins and add pluginMsw() to kubb.config.ts.
Dependencies
- 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/config'
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 }),
],
})