Migration: @kubb/plugin-faker
Part of the v4 → v5 migration guide. See the full option reference in @kubb/plugin-faker.
dateType, integerType, unknownType, emptySchemaType, and contentType moved to adapterOas. See Migration: @kubb/adapter-oas. resolver.resolveName replaces transformers.name, and macros replace transformers.schema. The generators option is gone.
Removed: paramsCasing
pluginFaker({ paramsCasing: 'camelcase' })Properties inside the generated path, query, and header mocks are now always camelCase, so drop the option. This keeps the mocks assignable to the types from @kubb/plugin-ts, which also camelCases parameters.
Generated output
Generic return type and intermediate variable
The create prefix stays, so createPet is still createPet. The signature and internal structure change. The factory now takes a generic TData and lifts the fake values into a defaultFakeData variable before the spread.
export function createPet(data?: Partial<Pet>): Pet {
return {
...{
id: faker.number.int(),
...
},
...(data || {}),
}
}
export function createPet<TData extends Partial<Pet> = object>(data?: TData) {
const defaultFakeData = {
id: faker.number.int(),
...
}
return {
...defaultFakeData,
...(data || {}),
} as Omit<typeof defaultFakeData, keyof TData> & TData
}The inferred return type keeps the fields you pass in data exactly as typed and fills the rest from defaultFakeData, so an override like createPet({ id: 1 }) reads back id as the literal you set rather than the wider schema type.