-
-
Notifications
You must be signed in to change notification settings - Fork 204
fix: zod; handle array union types #2159
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: zod; handle array union types #2159
Conversation
|
🦋 Changeset detectedLatest commit: 99ae4de The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
// TODO: parser - handle union | ||
// return compiler.typeArrayNode(compiler.typeUnionNode({ types: itemExpressions })); | ||
if (schema.logicalOperator === 'or') { | ||
arrayExpression = compiler.callExpression({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as the tests pass this looks good but please add a test like this https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts-tests/test/spec/3.1.x/validators-union-merge.json
You can either tack on another schema to that file or create a separate file altogether and add a new test case. Run pnpm openapi-ts-tests test:update
to update snapshots once you've done either of these approaches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All done! I updated the test you shared with me a bit.
@hey-api/client-axios
@hey-api/client-fetch
@hey-api/client-next
@hey-api/client-nuxt
@hey-api/nuxt
@hey-api/openapi-ts
@hey-api/vite-plugin
commit: |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2159 +/- ##
==========================================
- Coverage 22.49% 22.49% -0.01%
==========================================
Files 273 273
Lines 25496 25504 +8
Branches 950 950
==========================================
Hits 5736 5736
- Misses 19754 19762 +8
Partials 6 6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Lubos <lmenus@lmen.us>
@Joshua-hypt I'm not on a computer but see a lot of snapshot changes. Did you verify they're all correct? |
packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/zod/default/zod.gen.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it looks good now! Assuming you want to remove the comment let's do that and it can be released
}), | ||
], | ||
|
||
// compiler.callExpression({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a dead code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦 my bad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Fixes #2157