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

fix #257 to infer as object when only required array set #258

Merged
merged 1 commit into from
Dec 21, 2023

Conversation

marrowleaves
Copy link
Contributor

This is an attempt to fix #257

Now getZodSchema would treat schema object with required defined as an array of type object and correctly infer the type.
The fix also checks extra properties in required array but not defined in properties, inferred as additional props.

The fix doesn't handle the case when additionalProperties are defined and mixed with required array. It seems that the current implementation doesn't handle the mix of additionalProperties and properties either. But it would be easy to append the extraProperties string generated from required to the code string generated for additionalProperties, after it's properly handled.

Copy link

vercel bot commented Dec 20, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
openapi-zod-client ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 21, 2023 0:40am

@astahmer
Copy link
Owner

thank you for working on this ! could you add a changeset so I can merge it ?

@marrowleaves marrowleaves force-pushed the fix/257-required-props branch from e415a83 to dfe4dcf Compare December 21, 2023 00:38
@marrowleaves
Copy link
Contributor Author

thank you for working on this ! could you add a changeset so I can merge it ?

Sure, changeset text generated

@astahmer astahmer merged commit 8c80b43 into astahmer:main Dec 21, 2023
5 checks passed
@github-actions github-actions bot mentioned this pull request Dec 21, 2023
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.

Object without type attribute but has required array should be validated correctly
2 participants