Skip to content

Commit 31b3933

Browse files
Copilotmrlubos
andcommitted
Add changeset for Zod union deduplication fix
Co-authored-by: mrlubos <[email protected]>
1 parent 29d2479 commit 31b3933

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
"@hey-api/openapi-ts": patch
3+
---
4+
5+
Fix Zod schema union deduplication by including validation constraints in type ID
6+
7+
The Zod plugin was incorrectly deduplicating schemas with different validation constraints when using `anyOf`, resulting in incomplete union schemas. This fix ensures that schemas with different validation constraints (like `minLength`, `maxLength`, `minimum`, `maximum`, `pattern`, etc.) are properly preserved in unions.
8+
9+
For example, with an `anyOf` containing strings with different length constraints:
10+
- Before: `z.string().length(5)` (incorrect - only one constraint)
11+
- After: `z.union([z.string().length(5), z.string().length(2)])` (correct - proper union)
12+
13+
Fixes issue where the `deduplicateSchema` function was only considering `$ref`, `type`, `const`, and `format` when creating type identifiers, but ignored validation constraints.

0 commit comments

Comments
 (0)