Skip to content
Officialv5.1.3MITkubb >=5.0.0node >=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
Stijn Van Hulle

Stijn Van Hulle

@stijnvanhulle

Downloads
309.2K/ mo
Stars
8
Bundle size
375.7 kB
Updated
39m ago

Generate typed mock-data factories from OpenAPI schemas.

  • Override generated values with partial data.

Installation

bun add -d @kubb/plugin-faker

Or run kubb add plugin-faker to install the version the Kubb registry pins and add pluginFaker() to kubb.config.ts.

Dependencies

  • Add pluginTs for factory return types.
  • Generated factories require @faker-js/faker v9 or higher.

Example

kubb.config.ts
import { defineConfig } from 'kubb/config'
import { pluginTs } from '@kubb/plugin-ts'
import { pluginFaker } from '@kubb/plugin-faker'

export default defineConfig({
  input: './petStore.yaml',
  output: { path: './src/gen' },
  plugins: [
    pluginTs(),
    pluginFaker({ seed: [100] }),
  ],
})

Set typeMode to choose between inferred and declared model types for the factories.

See also