Skip to content
New issue

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

Fixes: Null and undefined value handling #286

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

sudowoodo200
Copy link

@sudowoodo200 sudowoodo200 commented Apr 14, 2024

Three fixes

  1. When there is a default value, the TS type will be optional. When .default() is used, Zod infers the input field to be optional, even if the field is required. This makes sense because we are parsing inputs. The strictly correct way is to build two types, Type and TypeInput. But it is bloated. This serves its purpose.
  2. Scattered nullable additions that we forgot before
  3. ZodSchema chaining for "oneOf" types. I suspect there are more bugs like this, but for future fixes.

This should now work on both the full petstore.yaml example and the gigantic openai specs

One JSDoc test is failing. I'm not sure what's going on.

Copy link

vercel bot commented Apr 14, 2024

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 14, 2024 1:25pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant