-
-
Notifications
You must be signed in to change notification settings - Fork 245
Fix allOf in array items being generated as union instead of intersection in Zod plugins #2736
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 allOf in array items being generated as union instead of intersection in Zod plugins #2736
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
🦋 Changeset detectedLatest commit: 078face 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 |
…gins Co-authored-by: mrlubos <[email protected]>
…Zod versions Co-authored-by: mrlubos <[email protected]>
Added comprehensive snapshot tests covering all OpenAPI versions (2.0.x, 3.0.x, 3.1.x) and all Zod compatibility versions (v3, v4, mini). Tests include cases for object intersections, primitive intersections, and refs with allOf. Commit: 50bb78d |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2736 +/- ##
==========================================
- Coverage 29.31% 29.24% -0.07%
==========================================
Files 388 388
Lines 37803 37893 +90
Branches 2260 2260
==========================================
Hits 11082 11082
- Misses 26691 26781 +90
Partials 30 30
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:
|
@copilot a few notes:
|
commit: |
…AML for all specs Co-authored-by: mrlubos <[email protected]>
Fixed all three issues:
All tests passing. Commit: f9e0d9d |
Fixes the generation of allOf in array items for Zod plugins.
Fix allOf in array items being generated as union instead of intersection in Zod plugins
Changes Made
Fixed the issue where arrays with
allOf
items were incorrectly generatingz.union()
instead of intersection in all Zod plugins (v3, v4, mini).Code Changes
allOf
with.and()
for objects andz.intersection()
for primitives ✨arrayTypeToZodSchema
to handleallOf
with.and()
for objects andz.intersection()
for primitivesarrayTypeToZodSchema
to handleallOf
withz.intersection()
for all typesTest Coverage
Organized tests efficiently:
openapi.test.ts
(removed duplicates from version-specific test files) ✨.and()
in v3/v4,z.intersection()
in mini)z.intersection()
)Total: 18 snapshot combinations (3 OpenAPI versions × 3 Zod versions × 2 test suites)
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.