You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working with an OpenAPI specification and have encountered an issue regarding default values when generating Zod schemas. Here's the scenario:
OpenAPI Definition
In my OpenAPI spec, I have a schema defined as follows:
components:
schemas:
RandomSchemaName:
properties:
random_column:
type: booleantitle: Random columndefault: false
When generating the Zod schema using Orval, the output looks like this:
random_column: zod.boolean().optional()
Expectation
I was expecting the default value to be included in the generated Zod schema, something like:
random_column: zod.boolean().default(false)
My Questions
Is the current behavior expected, or am I missing something in how default values are handled?
If this is the expected behavior, would modifying the generateZodValidationSchemaDefinition function like this be the correct approach to include default values?
If this isn't implemented yet, I’d be happy to contribute by helping implement this, but I want to ensure that updating only this function would address the issue.
I’d appreciate any guidance or clarification on this matter. Thanks for the fantastic tool!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I'm working with an OpenAPI specification and have encountered an issue regarding default values when generating Zod schemas. Here's the scenario:
OpenAPI Definition
In my OpenAPI spec, I have a schema defined as follows:
When generating the Zod schema using Orval, the output looks like this:
Expectation
I was expecting the default value to be included in the generated Zod schema, something like:
My Questions
Is the current behavior expected, or am I missing something in how default values are handled?
If this is the expected behavior, would modifying the generateZodValidationSchemaDefinition function like this be the correct approach to include default values?
I’d appreciate any guidance or clarification on this matter. Thanks for the fantastic tool!
Beta Was this translation helpful? Give feedback.
All reactions