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-faker

Generates a Faker.js mock-data factory for every schema in your OpenAPI spec. Use the factories in tests, Storybook, and local development without a running backend.

fakermock-datamocksfixturestestingcodegenopenapi
Downloads
152k / mo
Stars
Bundle size
309.4 kB
Updated
today

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

Dependencies

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 {  } from 'kubb'
import {  } from '@kubb/plugin-faker'
import {  } from '@kubb/plugin-ts'

export default ({
  : { : './petStore.yaml' },
  : { : './src/gen' },
  : [
    ({
      : { : './types' },
    }),
    ({
      : { : './mocks' },
      : [100],
    }),
  ],
})

See also