-
-
Notifications
You must be signed in to change notification settings - Fork 272
Fix Zod schema union deduplication by including validation constraints in type ID #2650
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
Conversation
|
@mrlubos 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
🦋 Changeset detectedLatest commit: 8bd26d5 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 |
…s in type ID Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
commit: |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2650 +/- ##
==========================================
+ Coverage 23.81% 23.83% +0.02%
==========================================
Files 379 379
Lines 36945 36960 +15
Branches 1623 1632 +9
==========================================
+ Hits 8798 8811 +13
- Misses 28134 28136 +2
Partials 13 13
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 add a changeset file with patch for the modified package. You can have a look at past releases or commits for the desired format. I'll let you know if I want any further changes |
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Added changeset file with patch version bump for @hey-api/openapi-ts package in commit 31b3933. The changeset documents the Zod union deduplication fix and follows the standard format used in this repository. |
The Zod plugin was incorrectly deduplicating schemas with different validation constraints when using
anyOf, resulting in incomplete union schemas. For example:{ "anyOf": [ { "type": "string", "minLength": 5, "maxLength": 5, "description": "Combination of ISO 639-1 and ISO 3166-1 alpha-2 separated by a hyphen." }, { "type": "string", "minLength": 2, "maxLength": 2, "description": "ISO 639-1 language code." } ] }Before this fix:
After this fix:
The issue was in the
deduplicateSchemafunction which only considered$ref,type,const, andformatwhen creating type identifiers, but ignored validation constraints likeminLength,maxLength,minimum,maximum,pattern, etc. This caused schemas with different constraints to be treated as duplicates and incorrectly merged.The fix enhances the type identification logic to include all validation constraints, ensuring that schemas with different validation rules are properly preserved in unions.
Changes:
packages/openapi-ts/src/ir/schema.tsto include validation constraints in type ID generationvalidators-string-constraints-union.jsonto prevent regressionFixes #2644.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.