@kubb/plugin-faker
@kubb/plugin-faker builds a mock-data factory for every schema in your OpenAPI spec with Faker.js. Call createPet() to get a realistic Pet object. Use the factories in tests, Storybook stories, and local development without a backend.
Installation
shell
bun add -d @kubb/plugin-faker@betashell
pnpm add -D @kubb/plugin-faker@betashell
npm install --save-dev @kubb/plugin-faker@betashell
yarn add -D @kubb/plugin-faker@betaDependencies
This plugin depends on @kubb/plugin-ts for the types each factory returns. Keep pluginTs() in the plugins array. No other plugin is required.
Example
typescript
import { defineConfig } from 'kubb'
import { pluginFaker } from '@kubb/plugin-faker'
import { pluginTs } from '@kubb/plugin-ts'
export default defineConfig({
input: './petStore.yaml',
output: { path: './src/gen' },
plugins: [
pluginTs({
output: { path: './types' },
}),
pluginFaker({
output: { path: './mocks' },
seed: [100],
}),
],
})