Skip to content

Commit 8bd26d5

Browse files
authored
Update fix-zod-union-deduplication.md
1 parent 31b3933 commit 8bd26d5

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

.changeset/fix-zod-union-deduplication.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,4 @@
22
"@hey-api/openapi-ts": patch
33
---
44

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.
5+
fix(parser): expand schema deduplication by including validation constraints in type ID

0 commit comments

Comments
 (0)