Skip to content
Officialv5.1.0MITkubb >=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
302.4K/ mo
Stars
8
Bundle size
370.2 kB
Updated
10h ago

Generate typed mock-data factories from OpenAPI schemas.

  • Override generated values with partial data.

Installation

bun add -d @kubb/plugin-faker

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