We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kubb
3.5.3
MacOS
kubb.config.ts
import { defineConfig } from "@kubb/core"; import { pluginOas } from "@kubb/plugin-oas"; import { pluginFaker } from "@kubb/plugin-faker"; import { pluginZod } from "@kubb/plugin-zod"; import { pluginTs } from "@kubb/plugin-ts"; export default defineConfig({ input: { path: "./src/openapi/test.yaml", }, output: { path: "./src/generated", }, plugins: [pluginOas(), pluginTs(), pluginZod(), pluginFaker()], });
openapi: 3.0.3 info: title: Test version: 1.0.0 paths: /item: get: responses: "200": description: OK content: application/json: schema: $ref: "#/components/schemas/Item" components: schemas: Item: type: object properties: name: type: string minLength: 3 price: type: number minimum: 5 required: - name - price
@tanstack-query
MSW
React
Vue
"@faker-js/faker": "9.4.0", "@kubb/cli": "3.5.3", "@kubb/core": "3.5.3", "@kubb/plugin-faker": "3.5.3", "@kubb/plugin-msw": "3.5.3", "@kubb/plugin-oas": "3.5.3", "@kubb/plugin-ts": "3.5.3",
The generated code looks as follows,
export function createItem(data?: Partial<Item>) { return { ...{ name: faker.string.alpha({ min: 3 }), price: faker.number.float({ min: 5, max: Number.MAX_VALUE }) }, ...(data || {}), } }
It throws an error on name because max is missing
https://fakerjs.dev/api/string.html#alpha
Every time
export function createItem(data?: Partial<Item>) { return { ...{ name: faker.string.alpha({ min: 3, max: SOME_DEFAULT_VALUE }), price: faker.number.float({ min: 5, max: Number.MAX_VALUE }) }, ...(data || {}), } }
This default value should either be configurable by the kubb config or some really large default value like 2,147,483,647 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length#description (But I'm not sure if this would have any performance impacts)
2,147,483,647
No response
The text was updated successfully, but these errors were encountered:
No branches or pull requests
What version of
kubb
is running?3.5.3
What kind of platform do you use?
MacOS
How does your
kubb.config.ts
config look likeSwagger/OpenAPI file?
What version of external packages are you using(
@tanstack-query
,MSW
,React
,Vue
, ...)What steps can reproduce the bug?
The generated code looks as follows,
It throws an error on name because max is missing
https://fakerjs.dev/api/string.html#alpha
How often does this bug happen?
Every time
What is the expected behavior?
This default value should either be configurable by the kubb config or some really large default value like
2,147,483,647
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length#description
(But I'm not sure if this would have any performance impacts)
Additional information
No response
The text was updated successfully, but these errors were encountered: