Closed dgadelha closed 4 months ago
The latest updates on your projects. Learn more about Vercel for Git ↗︎
Name | Status | Preview | Comments | Updated (UTC) |
---|---|---|---|---|
openapi-zod-client-rim4 | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Apr 10, 2024 3:40pm |
hey, is there a way to use this callback or make another dedicated for each schema if needed ? I'd like to avoid introducing another CLI flag
This callback seems to be very high-level, I'm not sure if it would be possible to achieve this without a complex code, but I might be wrong.
Your idea would be to add a callback at the beginning of getZodSchema
to allow modifying the schema?
this callback should hopefully make it possible for everyone to solve their custom use-cases just like yours 🙏
yes I think adding a callback in the options (TemplateContextOptions
) that you'd call somewhere near CodeMeta.assign
(so that you don't have to wrap each getZodSchema
) should be enough ? it's been a while since the last time I added such feature so I might be wrong
Alright, I'll take a look into this.
This PR adds a new option,
addNullishToPartial
, as well as a new CLI flag,--add-nullish-to-partial
, that adds.nullish()
to all.partial()
objects, as a workaround for the issue https://github.com/colinhacks/zod/issues/2893This is because partial objects allow
undefined
values, but notnull
values, which is causing an unexpected error for an API I'm currently integrating.As there isn't any other way to achieve this with the currently-implemented options, I've added this feature as an opt-in flag with no breaking changes.