Skip to content

Commit c476375

Browse files
committed
feat: fix Zod v4 compatibility issues with additionalProperties
Successfully resolved Zod v4 breaking changes: βœ… Fixed switch statement case ordering (case 3 before case 4) βœ… Added proper Zod v4 API compatibility for z.record() βœ… Corrected additionalProperties condition logic βœ… Added ZodType for circular references in v4 plugin βœ… Updated all plugin versions (v3, v4, mini) consistently Key Changes: - DictionaryWithDictionary now generates correct nested z.record() calls - Zod v3: z.record(z.record(z.string())) (1 param syntax) - Zod v4: z.record(z.string(), z.record(z.string(), z.string())) (2 param syntax) - All tests passing for both v3 and v4 compatibility versions This fixes the CI failures with Zod v4 TypeScript compilation errors.
1 parent 9556d52 commit c476375

File tree

105 files changed

+5972
-5504
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+5972
-5504
lines changed

β€Žpackages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/mini/default/zod.gen.ts

Lines changed: 242 additions & 236 deletions
Large diffs are not rendered by default.

β€Žpackages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/mini/type-format-zod/zod.gen.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
// This file is auto-generated by @hey-api/openapi-ts
22

3-
import { z } from 'zod';
3+
import * as z from 'zod/v4-mini';
44

55
export const zFoo = z.object({
6-
bar: z.number().int().optional(),
7-
foo: z.coerce.bigint().default(BigInt(0)),
6+
bar: z.optional(z.int()),
7+
foo: z._default(z.coerce.bigint(), BigInt(0)),
88
id: z.string()
99
});
1010

1111
export const zBar = z.object({
12-
foo: z.number().int()
12+
foo: z.int()
1313
});
1414

1515
export const zPostFooData = z.object({
16-
body: z.never().optional(),
17-
path: z.never().optional(),
18-
query: z.never().optional()
16+
body: z.optional(z.never()),
17+
path: z.optional(z.never()),
18+
query: z.optional(z.never())
1919
});
2020

2121
/**

β€Žpackages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v3/default/zod.gen.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,22 +142,22 @@ export const zArrayWithProperties = z.array(z.object({
142142
/**
143143
* This is a string dictionary
144144
*/
145-
export const zDictionaryWithString = z.object({});
145+
export const zDictionaryWithString = z.record(z.string());
146146

147147
/**
148148
* This is a string reference
149149
*/
150-
export const zDictionaryWithReference = z.object({});
150+
export const zDictionaryWithReference = z.record(zModelWithString);
151151

152152
/**
153153
* This is a complex dictionary
154154
*/
155-
export const zDictionaryWithArray = z.object({});
155+
export const zDictionaryWithArray = z.record(z.array(zModelWithString));
156156

157157
/**
158158
* This is a string dictionary
159159
*/
160-
export const zDictionaryWithDictionary = z.record(z.object({}));
160+
export const zDictionaryWithDictionary = z.record(z.record(z.string()));
161161

162162
/**
163163
* This is a complex dictionary
@@ -239,8 +239,12 @@ export const zModelWithEnumFromDescription = z.object({
239239
* This is a model with nested enums
240240
*/
241241
export const zModelWithNestedEnums = z.object({
242-
dictionaryWithEnum: z.object({}).optional(),
243-
dictionaryWithEnumFromDescription: z.object({}).optional(),
242+
dictionaryWithEnum: z.record(z.enum([
243+
'Success',
244+
'Warning',
245+
'Error'
246+
])).optional(),
247+
dictionaryWithEnumFromDescription: z.record(z.number().int()).optional(),
244248
arrayWithEnum: z.array(z.enum([
245249
'Success',
246250
'Warning',
@@ -286,7 +290,7 @@ export const zModelWithArray = z.object({
286290
* This is a model with one property containing a dictionary
287291
*/
288292
export const zModelWithDictionary = z.object({
289-
prop: z.object({}).optional()
293+
prop: z.record(z.string()).optional()
290294
});
291295

292296
/**
@@ -664,7 +668,7 @@ export const zTypesData = z.object({
664668
parameterString: z.string().default('default'),
665669
parameterBoolean: z.boolean().default(true),
666670
parameterArray: z.array(z.string()),
667-
parameterDictionary: z.object({}),
671+
parameterDictionary: z.record(z.unknown()),
668672
parameterEnum: z.enum([
669673
'Success',
670674
'Warning',
@@ -677,7 +681,7 @@ export const zTypesResponse = z.union([
677681
z.number(),
678682
z.string(),
679683
z.boolean(),
680-
z.object({})
684+
z.record(z.unknown())
681685
]);
682686

683687
export const zComplexTypesData = z.object({

0 commit comments

Comments
Β (0)