fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #2287 from MaxwellAt/fix/allof-additionalProperties-false

Fix/allof additional properties false

authored by

Lubos and committed by
GitHub
226e8208 4067da8c

+841 -424
+5
.changeset/sweet-swans-shout.md
··· 1 + --- 2 + "@hey-api/openapi-ts": patch 3 + --- 4 + 5 + fix(zod): improve handling of additional properties
+1 -1
README.md
··· 1 - packages/openapi-ts/README.md 1 + packages/openapi-ts/README.md
+7
packages/openapi-ts-tests/main/test/2.0.x.test.ts
··· 46 46 const scenarios = [ 47 47 { 48 48 config: createConfig({ 49 + input: 'additional-properties-false.json', 50 + output: 'additional-properties-false', 51 + }), 52 + description: 'forbids arbitrary properties on objects', 53 + }, 54 + { 55 + config: createConfig({ 49 56 input: 'additional-properties-true.json', 50 57 output: 'additional-properties-true', 51 58 }),
+2
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/additional-properties-false/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + export * from './types.gen';
+15
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/additional-properties-false/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type Foo = { 4 + foo: string; 5 + }; 6 + 7 + export type Bar = Foo & {}; 8 + 9 + export type Baz = Foo & { 10 + bar: string; 11 + }; 12 + 13 + export type ClientOptions = { 14 + baseUrl: string; 15 + };
+1 -3
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/additional-properties-false/types.gen.ts
··· 4 4 foo: string; 5 5 }; 6 6 7 - export type Bar = Foo & { 8 - [key: string]: never; 9 - }; 7 + export type Bar = Foo & {}; 10 8 11 9 export type Baz = Foo & { 12 10 bar: string;
+1 -3
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/additional-properties-false/types.gen.ts
··· 4 4 foo: string; 5 5 }; 6 6 7 - export type Bar = Foo & { 8 - [key: string]: never; 9 - }; 7 + export type Bar = Foo & {}; 10 8 11 9 export type Baz = Foo & { 12 10 bar: string;
+47
packages/openapi-ts-tests/specs/2.0.x/additional-properties-false.json
··· 1 + { 2 + "swagger": "2.0", 3 + "info": { 4 + "title": "OpenAPI 2.0 additional properties false example", 5 + "version": "1" 6 + }, 7 + "definitions": { 8 + "Foo": { 9 + "required": ["foo"], 10 + "type": "object", 11 + "properties": { 12 + "foo": { 13 + "type": "string" 14 + } 15 + }, 16 + "additionalProperties": false 17 + }, 18 + "Bar": { 19 + "allOf": [ 20 + { 21 + "$ref": "#/definitions/Foo" 22 + }, 23 + { 24 + "type": "object", 25 + "additionalProperties": false 26 + } 27 + ] 28 + }, 29 + "Baz": { 30 + "allOf": [ 31 + { 32 + "$ref": "#/definitions/Foo" 33 + }, 34 + { 35 + "required": ["bar"], 36 + "type": "object", 37 + "properties": { 38 + "bar": { 39 + "type": "string" 40 + } 41 + }, 42 + "additionalProperties": false 43 + } 44 + ] 45 + } 46 + } 47 + }
+2
packages/openapi-ts-tests/test/__snapshots__/2.0.x/additional-properties-false/index.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + export * from './types.gen';
+15
packages/openapi-ts-tests/test/__snapshots__/2.0.x/additional-properties-false/types.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + export type Foo = { 4 + foo: string; 5 + }; 6 + 7 + export type Bar = Foo & {}; 8 + 9 + export type Baz = Foo & { 10 + bar: string; 11 + }; 12 + 13 + export type ClientOptions = { 14 + baseUrl: string; 15 + };
+13 -9
packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/mini/default/zod.gen.ts
··· 142 142 /** 143 143 * This is a string dictionary 144 144 */ 145 - export const zDictionaryWithString = z.object({}); 145 + export const zDictionaryWithString = z.record(z.string(), z.string()); 146 146 147 147 /** 148 148 * This is a string reference 149 149 */ 150 - export const zDictionaryWithReference = z.object({}); 150 + export const zDictionaryWithReference = z.record(z.string(), zModelWithString); 151 151 152 152 /** 153 153 * This is a complex dictionary 154 154 */ 155 - export const zDictionaryWithArray = z.object({}); 155 + export const zDictionaryWithArray = z.record(z.string(), z.array(zModelWithString)); 156 156 157 157 /** 158 158 * This is a string dictionary 159 159 */ 160 - export const zDictionaryWithDictionary = z.record(z.string(), z.object({})); 160 + export const zDictionaryWithDictionary = z.record(z.string(), z.record(z.string(), z.string())); 161 161 162 162 /** 163 163 * This is a complex dictionary ··· 239 239 * This is a model with nested enums 240 240 */ 241 241 export const zModelWithNestedEnums = z.object({ 242 - dictionaryWithEnum: z.optional(z.object({})), 243 - dictionaryWithEnumFromDescription: z.optional(z.object({})), 242 + dictionaryWithEnum: z.optional(z.record(z.string(), z.enum([ 243 + 'Success', 244 + 'Warning', 245 + 'Error' 246 + ]))), 247 + dictionaryWithEnumFromDescription: z.optional(z.record(z.string(), z.int())), 244 248 arrayWithEnum: z.optional(z.array(z.enum([ 245 249 'Success', 246 250 'Warning', ··· 286 290 * This is a model with one property containing a dictionary 287 291 */ 288 292 export const zModelWithDictionary = z.object({ 289 - prop: z.optional(z.object({})) 293 + prop: z.optional(z.record(z.string(), z.string())) 290 294 }); 291 295 292 296 /** ··· 666 670 parameterString: z._default(z.string(), 'default'), 667 671 parameterBoolean: z._default(z.boolean(), true), 668 672 parameterArray: z.array(z.string()), 669 - parameterDictionary: z.object({}), 673 + parameterDictionary: z.record(z.string(), z.unknown()), 670 674 parameterEnum: z.enum([ 671 675 'Success', 672 676 'Warning', ··· 679 683 z.number(), 680 684 z.string(), 681 685 z.boolean(), 682 - z.object({}) 686 + z.record(z.string(), z.unknown()) 683 687 ]); 684 688 685 689 export const zComplexTypesData = z.object({
+13 -9
packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v3/default/zod.gen.ts
··· 142 142 /** 143 143 * This is a string dictionary 144 144 */ 145 - export const zDictionaryWithString = z.object({}); 145 + export const zDictionaryWithString = z.record(z.string()); 146 146 147 147 /** 148 148 * This is a string reference 149 149 */ 150 - export const zDictionaryWithReference = z.object({}); 150 + export const zDictionaryWithReference = z.record(zModelWithString); 151 151 152 152 /** 153 153 * This is a complex dictionary 154 154 */ 155 - export const zDictionaryWithArray = z.object({}); 155 + export const zDictionaryWithArray = z.record(z.array(zModelWithString)); 156 156 157 157 /** 158 158 * This is a string dictionary 159 159 */ 160 - export const zDictionaryWithDictionary = z.record(z.object({})); 160 + export const zDictionaryWithDictionary = z.record(z.record(z.string())); 161 161 162 162 /** 163 163 * This is a complex dictionary ··· 239 239 * This is a model with nested enums 240 240 */ 241 241 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(), 244 248 arrayWithEnum: z.array(z.enum([ 245 249 'Success', 246 250 'Warning', ··· 286 290 * This is a model with one property containing a dictionary 287 291 */ 288 292 export const zModelWithDictionary = z.object({ 289 - prop: z.object({}).optional() 293 + prop: z.record(z.string()).optional() 290 294 }); 291 295 292 296 /** ··· 664 668 parameterString: z.string().default('default'), 665 669 parameterBoolean: z.boolean().default(true), 666 670 parameterArray: z.array(z.string()), 667 - parameterDictionary: z.object({}), 671 + parameterDictionary: z.record(z.unknown()), 668 672 parameterEnum: z.enum([ 669 673 'Success', 670 674 'Warning', ··· 677 681 z.number(), 678 682 z.string(), 679 683 z.boolean(), 680 - z.object({}) 684 + z.record(z.unknown()) 681 685 ]); 682 686 683 687 export const zComplexTypesData = z.object({
+13 -9
packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v4/default/zod.gen.ts
··· 142 142 /** 143 143 * This is a string dictionary 144 144 */ 145 - export const zDictionaryWithString = z.object({}); 145 + export const zDictionaryWithString = z.record(z.string(), z.string()); 146 146 147 147 /** 148 148 * This is a string reference 149 149 */ 150 - export const zDictionaryWithReference = z.object({}); 150 + export const zDictionaryWithReference = z.record(z.string(), zModelWithString); 151 151 152 152 /** 153 153 * This is a complex dictionary 154 154 */ 155 - export const zDictionaryWithArray = z.object({}); 155 + export const zDictionaryWithArray = z.record(z.string(), z.array(zModelWithString)); 156 156 157 157 /** 158 158 * This is a string dictionary 159 159 */ 160 - export const zDictionaryWithDictionary = z.record(z.string(), z.object({})); 160 + export const zDictionaryWithDictionary = z.record(z.string(), z.record(z.string(), z.string())); 161 161 162 162 /** 163 163 * This is a complex dictionary ··· 239 239 * This is a model with nested enums 240 240 */ 241 241 export const zModelWithNestedEnums = z.object({ 242 - dictionaryWithEnum: z.optional(z.object({})), 243 - dictionaryWithEnumFromDescription: z.optional(z.object({})), 242 + dictionaryWithEnum: z.optional(z.record(z.string(), z.enum([ 243 + 'Success', 244 + 'Warning', 245 + 'Error' 246 + ]))), 247 + dictionaryWithEnumFromDescription: z.optional(z.record(z.string(), z.int())), 244 248 arrayWithEnum: z.optional(z.array(z.enum([ 245 249 'Success', 246 250 'Warning', ··· 286 290 * This is a model with one property containing a dictionary 287 291 */ 288 292 export const zModelWithDictionary = z.object({ 289 - prop: z.optional(z.object({})) 293 + prop: z.optional(z.record(z.string(), z.string())) 290 294 }); 291 295 292 296 /** ··· 666 670 parameterString: z.string().default('default'), 667 671 parameterBoolean: z.boolean().default(true), 668 672 parameterArray: z.array(z.string()), 669 - parameterDictionary: z.object({}), 673 + parameterDictionary: z.record(z.string(), z.unknown()), 670 674 parameterEnum: z.enum([ 671 675 'Success', 672 676 'Warning', ··· 679 683 z.number(), 680 684 z.string(), 681 685 z.boolean(), 682 - z.object({}) 686 + z.record(z.string(), z.unknown()) 683 687 ]); 684 688 685 689 export const zComplexTypesData = z.object({
+47 -28
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/default/zod.gen.ts
··· 200 200 /** 201 201 * This is a string dictionary 202 202 */ 203 - export const zDictionaryWithString = z.object({}); 203 + export const zDictionaryWithString = z.record(z.string(), z.string()); 204 204 205 205 export const zDictionaryWithPropertiesAndAdditionalProperties = z.object({ 206 206 foo: z.optional(z.number()), ··· 210 210 /** 211 211 * This is a string reference 212 212 */ 213 - export const zDictionaryWithReference = z.object({}); 213 + export const zDictionaryWithReference = z.record(z.string(), zModelWithString); 214 214 215 215 /** 216 216 * This is a complex dictionary 217 217 */ 218 - export const zDictionaryWithArray = z.object({}); 218 + export const zDictionaryWithArray = z.record(z.string(), z.array(zModelWithString)); 219 219 220 220 /** 221 221 * This is a string dictionary 222 222 */ 223 - export const zDictionaryWithDictionary = z.record(z.string(), z.object({})); 223 + export const zDictionaryWithDictionary = z.record(z.string(), z.record(z.string(), z.string())); 224 224 225 225 /** 226 226 * This is a complex dictionary ··· 325 325 * This is a model with nested enums 326 326 */ 327 327 export const zModelWithNestedEnums = z.object({ 328 - dictionaryWithEnum: z.optional(z.object({})), 329 - dictionaryWithEnumFromDescription: z.optional(z.object({})), 328 + dictionaryWithEnum: z.optional(z.record(z.string(), z.enum([ 329 + 'Success', 330 + 'Warning', 331 + 'Error' 332 + ]))), 333 + dictionaryWithEnumFromDescription: z.optional(z.record(z.string(), z.int())), 330 334 arrayWithEnum: z.optional(z.array(z.enum([ 331 335 'Success', 332 336 'Warning', ··· 396 400 * This is a model with one property containing a dictionary 397 401 */ 398 402 export const zModelWithDictionary = z.object({ 399 - prop: z.optional(z.object({})) 403 + prop: z.optional(z.record(z.string(), z.string())) 400 404 }); 401 405 402 406 /** ··· 555 559 export const zCompositionWithOneOfAndSimpleDictionary = z.object({ 556 560 propA: z.optional(z.union([ 557 561 z.boolean(), 558 - z.object({}) 562 + z.record(z.string(), z.number()) 559 563 ])) 560 564 }); 561 565 ··· 565 569 export const zCompositionWithOneOfAndSimpleArrayDictionary = z.object({ 566 570 propA: z.optional(z.union([ 567 571 z.boolean(), 568 - z.object({}) 572 + z.record(z.string(), z.array(z.boolean())) 569 573 ])) 570 574 }); 571 575 ··· 575 579 export const zCompositionWithOneOfAndComplexArrayDictionary = z.object({ 576 580 propA: z.optional(z.union([ 577 581 z.boolean(), 578 - z.object({}) 582 + z.record(z.string(), z.array(z.union([ 583 + z.number(), 584 + z.string() 585 + ]))) 579 586 ])) 580 587 }); 581 588 ··· 720 727 /** 721 728 * This is a free-form object without additionalProperties. 722 729 */ 723 - export const zFreeFormObjectWithoutAdditionalProperties = z.object({}); 730 + export const zFreeFormObjectWithoutAdditionalProperties = z.record(z.string(), z.unknown()); 724 731 725 732 /** 726 733 * This is a free-form object with additionalProperties: true. 727 734 */ 728 - export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.object({}); 735 + export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.record(z.string(), z.unknown()); 729 736 730 737 /** 731 738 * This is a free-form object with additionalProperties: {}. 732 739 */ 733 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.object({}); 740 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.record(z.string(), z.unknown()); 734 741 735 742 export const zModelWithConst = z.object({ 736 743 String: z.optional(z.enum([ ··· 1005 1012 preconditions: z.optional(zIoK8sApimachineryPkgApisMetaV1Preconditions) 1006 1013 }); 1007 1014 1008 - export const zAdditionalPropertiesUnknownIssue = z.object({}); 1015 + export const zAdditionalPropertiesUnknownIssue = z.record(z.string(), z.union([ 1016 + z.string(), 1017 + z.number() 1018 + ])); 1009 1019 1010 - export const zAdditionalPropertiesUnknownIssue2 = z.object({}); 1020 + export const zAdditionalPropertiesUnknownIssue2 = z.record(z.string(), z.union([ 1021 + z.string(), 1022 + z.number() 1023 + ])); 1011 1024 1012 1025 export const zAdditionalPropertiesUnknownIssue3 = z.intersection(z.string(), z.object({ 1013 - entries: z.object({}) 1026 + entries: z.record(z.string(), zAdditionalPropertiesUnknownIssue) 1014 1027 })); 1015 1028 1016 1029 export const zAdditionalPropertiesIntegerIssue = z.object({ ··· 1024 1037 z.null() 1025 1038 ])), 1026 1039 hasError: z.optional(z.readonly(z.boolean())), 1027 - data: z.optional(z.object({})) 1040 + data: z.optional(z.record(z.string(), z.never())) 1028 1041 }); 1029 1042 1030 1043 export const zGenericSchemaDuplicateIssue1SystemString = z.object({ ··· 1185 1198 /** 1186 1199 * This is a string dictionary 1187 1200 */ 1188 - export const zDictionaryWithStringWritable = z.object({}); 1201 + export const zDictionaryWithStringWritable = z.record(z.string(), z.string()); 1189 1202 1190 1203 /** 1191 1204 * This is a string dictionary 1192 1205 */ 1193 - export const zDictionaryWithDictionaryWritable = z.record(z.string(), z.object({})); 1206 + export const zDictionaryWithDictionaryWritable = z.record(z.string(), z.record(z.string(), z.string())); 1194 1207 1195 1208 /** 1196 1209 * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) ··· 1223 1236 /** 1224 1237 * This is a free-form object without additionalProperties. 1225 1238 */ 1226 - export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.object({}); 1239 + export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.record(z.string(), z.unknown()); 1227 1240 1228 1241 /** 1229 1242 * This is a free-form object with additionalProperties: true. 1230 1243 */ 1231 - export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.object({}); 1244 + export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.record(z.string(), z.unknown()); 1232 1245 1233 1246 /** 1234 1247 * This is a free-form object with additionalProperties: {}. 1235 1248 */ 1236 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.object({}); 1249 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.record(z.string(), z.unknown()); 1237 1250 1238 1251 /** 1239 1252 * Some % character ··· 1334 1347 */ 1335 1348 export const zDeleteFooData2Writable = z.string(); 1336 1349 1337 - export const zAdditionalPropertiesUnknownIssueWritable = z.object({}); 1350 + export const zAdditionalPropertiesUnknownIssueWritable = z.record(z.string(), z.union([ 1351 + z.string(), 1352 + z.number() 1353 + ])); 1338 1354 1339 - export const zAdditionalPropertiesUnknownIssue2Writable = z.object({}); 1355 + export const zAdditionalPropertiesUnknownIssue2Writable = z.record(z.string(), z.union([ 1356 + z.string(), 1357 + z.number() 1358 + ])); 1340 1359 1341 1360 export const zOneOfAllOfIssueWritable = z.union([ 1342 1361 z.intersection(z.union([ ··· 1492 1511 1493 1512 export const zCallWithParametersData = z.object({ 1494 1513 body: z.union([ 1495 - z.object({}), 1514 + z.record(z.string(), z.unknown()), 1496 1515 z.null() 1497 1516 ]), 1498 1517 path: z.object({ ··· 1800 1819 z.null() 1801 1820 ]), true), 1802 1821 parameterObject: z._default(z.union([ 1803 - z.object({}), 1822 + z.record(z.string(), z.unknown()), 1804 1823 z.null() 1805 1824 ]), null), 1806 1825 parameterArray: z.union([ ··· 1808 1827 z.null() 1809 1828 ]), 1810 1829 parameterDictionary: z.union([ 1811 - z.object({}), 1830 + z.record(z.string(), z.unknown()), 1812 1831 z.null() 1813 1832 ]), 1814 1833 parameterEnum: z.enum([ ··· 1823 1842 z.number(), 1824 1843 z.string(), 1825 1844 z.boolean(), 1826 - z.object({}) 1845 + z.record(z.string(), z.unknown()) 1827 1846 ]); 1828 1847 1829 1848 export const zUploadFileData = z.object({
+47 -28
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v3/default/zod.gen.ts
··· 200 200 /** 201 201 * This is a string dictionary 202 202 */ 203 - export const zDictionaryWithString = z.object({}); 203 + export const zDictionaryWithString = z.record(z.string()); 204 204 205 205 export const zDictionaryWithPropertiesAndAdditionalProperties = z.object({ 206 206 foo: z.number().optional(), ··· 210 210 /** 211 211 * This is a string reference 212 212 */ 213 - export const zDictionaryWithReference = z.object({}); 213 + export const zDictionaryWithReference = z.record(zModelWithString); 214 214 215 215 /** 216 216 * This is a complex dictionary 217 217 */ 218 - export const zDictionaryWithArray = z.object({}); 218 + export const zDictionaryWithArray = z.record(z.array(zModelWithString)); 219 219 220 220 /** 221 221 * This is a string dictionary 222 222 */ 223 - export const zDictionaryWithDictionary = z.record(z.object({})); 223 + export const zDictionaryWithDictionary = z.record(z.record(z.string())); 224 224 225 225 /** 226 226 * This is a complex dictionary ··· 325 325 * This is a model with nested enums 326 326 */ 327 327 export const zModelWithNestedEnums = z.object({ 328 - dictionaryWithEnum: z.object({}).optional(), 329 - dictionaryWithEnumFromDescription: z.object({}).optional(), 328 + dictionaryWithEnum: z.record(z.enum([ 329 + 'Success', 330 + 'Warning', 331 + 'Error' 332 + ])).optional(), 333 + dictionaryWithEnumFromDescription: z.record(z.number().int()).optional(), 330 334 arrayWithEnum: z.array(z.enum([ 331 335 'Success', 332 336 'Warning', ··· 396 400 * This is a model with one property containing a dictionary 397 401 */ 398 402 export const zModelWithDictionary = z.object({ 399 - prop: z.object({}).optional() 403 + prop: z.record(z.string()).optional() 400 404 }); 401 405 402 406 /** ··· 553 557 export const zCompositionWithOneOfAndSimpleDictionary = z.object({ 554 558 propA: z.union([ 555 559 z.boolean(), 556 - z.object({}) 560 + z.record(z.number()) 557 561 ]).optional() 558 562 }); 559 563 ··· 563 567 export const zCompositionWithOneOfAndSimpleArrayDictionary = z.object({ 564 568 propA: z.union([ 565 569 z.boolean(), 566 - z.object({}) 570 + z.record(z.array(z.boolean())) 567 571 ]).optional() 568 572 }); 569 573 ··· 573 577 export const zCompositionWithOneOfAndComplexArrayDictionary = z.object({ 574 578 propA: z.union([ 575 579 z.boolean(), 576 - z.object({}) 580 + z.record(z.array(z.union([ 581 + z.number(), 582 + z.string() 583 + ]))) 577 584 ]).optional() 578 585 }); 579 586 ··· 718 725 /** 719 726 * This is a free-form object without additionalProperties. 720 727 */ 721 - export const zFreeFormObjectWithoutAdditionalProperties = z.object({}); 728 + export const zFreeFormObjectWithoutAdditionalProperties = z.record(z.unknown()); 722 729 723 730 /** 724 731 * This is a free-form object with additionalProperties: true. 725 732 */ 726 - export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.object({}); 733 + export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.record(z.unknown()); 727 734 728 735 /** 729 736 * This is a free-form object with additionalProperties: {}. 730 737 */ 731 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.object({}); 738 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.record(z.unknown()); 732 739 733 740 export const zModelWithConst = z.object({ 734 741 String: z.enum([ ··· 1003 1010 preconditions: zIoK8sApimachineryPkgApisMetaV1Preconditions.optional() 1004 1011 }); 1005 1012 1006 - export const zAdditionalPropertiesUnknownIssue = z.object({}); 1013 + export const zAdditionalPropertiesUnknownIssue = z.record(z.union([ 1014 + z.string(), 1015 + z.number() 1016 + ])); 1007 1017 1008 - export const zAdditionalPropertiesUnknownIssue2 = z.object({}); 1018 + export const zAdditionalPropertiesUnknownIssue2 = z.record(z.union([ 1019 + z.string(), 1020 + z.number() 1021 + ])); 1009 1022 1010 1023 export const zAdditionalPropertiesUnknownIssue3 = z.intersection(z.string(), z.object({ 1011 - entries: z.object({}) 1024 + entries: z.record(zAdditionalPropertiesUnknownIssue) 1012 1025 })); 1013 1026 1014 1027 export const zAdditionalPropertiesIntegerIssue = z.object({ ··· 1022 1035 z.null() 1023 1036 ]).optional(), 1024 1037 hasError: z.boolean().readonly().optional(), 1025 - data: z.object({}).optional() 1038 + data: z.record(z.never()).optional() 1026 1039 }); 1027 1040 1028 1041 export const zGenericSchemaDuplicateIssue1SystemString = z.object({ ··· 1183 1196 /** 1184 1197 * This is a string dictionary 1185 1198 */ 1186 - export const zDictionaryWithStringWritable = z.object({}); 1199 + export const zDictionaryWithStringWritable = z.record(z.string()); 1187 1200 1188 1201 /** 1189 1202 * This is a string dictionary 1190 1203 */ 1191 - export const zDictionaryWithDictionaryWritable = z.record(z.object({})); 1204 + export const zDictionaryWithDictionaryWritable = z.record(z.record(z.string())); 1192 1205 1193 1206 /** 1194 1207 * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) ··· 1221 1234 /** 1222 1235 * This is a free-form object without additionalProperties. 1223 1236 */ 1224 - export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.object({}); 1237 + export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.record(z.unknown()); 1225 1238 1226 1239 /** 1227 1240 * This is a free-form object with additionalProperties: true. 1228 1241 */ 1229 - export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.object({}); 1242 + export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.record(z.unknown()); 1230 1243 1231 1244 /** 1232 1245 * This is a free-form object with additionalProperties: {}. 1233 1246 */ 1234 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.object({}); 1247 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.record(z.unknown()); 1235 1248 1236 1249 /** 1237 1250 * Some % character ··· 1332 1345 */ 1333 1346 export const zDeleteFooData2Writable = z.string(); 1334 1347 1335 - export const zAdditionalPropertiesUnknownIssueWritable = z.object({}); 1348 + export const zAdditionalPropertiesUnknownIssueWritable = z.record(z.union([ 1349 + z.string(), 1350 + z.number() 1351 + ])); 1336 1352 1337 - export const zAdditionalPropertiesUnknownIssue2Writable = z.object({}); 1353 + export const zAdditionalPropertiesUnknownIssue2Writable = z.record(z.union([ 1354 + z.string(), 1355 + z.number() 1356 + ])); 1338 1357 1339 1358 export const zOneOfAllOfIssueWritable = z.union([ 1340 1359 z.intersection(z.union([ ··· 1490 1509 1491 1510 export const zCallWithParametersData = z.object({ 1492 1511 body: z.union([ 1493 - z.object({}), 1512 + z.record(z.unknown()), 1494 1513 z.null() 1495 1514 ]), 1496 1515 path: z.object({ ··· 1798 1817 z.null() 1799 1818 ]).default(true), 1800 1819 parameterObject: z.union([ 1801 - z.object({}), 1820 + z.record(z.unknown()), 1802 1821 z.null() 1803 1822 ]).default(null), 1804 1823 parameterArray: z.union([ ··· 1806 1825 z.null() 1807 1826 ]), 1808 1827 parameterDictionary: z.union([ 1809 - z.object({}), 1828 + z.record(z.unknown()), 1810 1829 z.null() 1811 1830 ]), 1812 1831 parameterEnum: z.enum([ ··· 1821 1840 z.number(), 1822 1841 z.string(), 1823 1842 z.boolean(), 1824 - z.object({}) 1843 + z.record(z.unknown()) 1825 1844 ]); 1826 1845 1827 1846 export const zUploadFileData = z.object({
+47 -28
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/default/zod.gen.ts
··· 200 200 /** 201 201 * This is a string dictionary 202 202 */ 203 - export const zDictionaryWithString = z.object({}); 203 + export const zDictionaryWithString = z.record(z.string(), z.string()); 204 204 205 205 export const zDictionaryWithPropertiesAndAdditionalProperties = z.object({ 206 206 foo: z.optional(z.number()), ··· 210 210 /** 211 211 * This is a string reference 212 212 */ 213 - export const zDictionaryWithReference = z.object({}); 213 + export const zDictionaryWithReference = z.record(z.string(), zModelWithString); 214 214 215 215 /** 216 216 * This is a complex dictionary 217 217 */ 218 - export const zDictionaryWithArray = z.object({}); 218 + export const zDictionaryWithArray = z.record(z.string(), z.array(zModelWithString)); 219 219 220 220 /** 221 221 * This is a string dictionary 222 222 */ 223 - export const zDictionaryWithDictionary = z.record(z.string(), z.object({})); 223 + export const zDictionaryWithDictionary = z.record(z.string(), z.record(z.string(), z.string())); 224 224 225 225 /** 226 226 * This is a complex dictionary ··· 325 325 * This is a model with nested enums 326 326 */ 327 327 export const zModelWithNestedEnums = z.object({ 328 - dictionaryWithEnum: z.optional(z.object({})), 329 - dictionaryWithEnumFromDescription: z.optional(z.object({})), 328 + dictionaryWithEnum: z.optional(z.record(z.string(), z.enum([ 329 + 'Success', 330 + 'Warning', 331 + 'Error' 332 + ]))), 333 + dictionaryWithEnumFromDescription: z.optional(z.record(z.string(), z.int())), 330 334 arrayWithEnum: z.optional(z.array(z.enum([ 331 335 'Success', 332 336 'Warning', ··· 396 400 * This is a model with one property containing a dictionary 397 401 */ 398 402 export const zModelWithDictionary = z.object({ 399 - prop: z.optional(z.object({})) 403 + prop: z.optional(z.record(z.string(), z.string())) 400 404 }); 401 405 402 406 /** ··· 555 559 export const zCompositionWithOneOfAndSimpleDictionary = z.object({ 556 560 propA: z.optional(z.union([ 557 561 z.boolean(), 558 - z.object({}) 562 + z.record(z.string(), z.number()) 559 563 ])) 560 564 }); 561 565 ··· 565 569 export const zCompositionWithOneOfAndSimpleArrayDictionary = z.object({ 566 570 propA: z.optional(z.union([ 567 571 z.boolean(), 568 - z.object({}) 572 + z.record(z.string(), z.array(z.boolean())) 569 573 ])) 570 574 }); 571 575 ··· 575 579 export const zCompositionWithOneOfAndComplexArrayDictionary = z.object({ 576 580 propA: z.optional(z.union([ 577 581 z.boolean(), 578 - z.object({}) 582 + z.record(z.string(), z.array(z.union([ 583 + z.number(), 584 + z.string() 585 + ]))) 579 586 ])) 580 587 }); 581 588 ··· 720 727 /** 721 728 * This is a free-form object without additionalProperties. 722 729 */ 723 - export const zFreeFormObjectWithoutAdditionalProperties = z.object({}); 730 + export const zFreeFormObjectWithoutAdditionalProperties = z.record(z.string(), z.unknown()); 724 731 725 732 /** 726 733 * This is a free-form object with additionalProperties: true. 727 734 */ 728 - export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.object({}); 735 + export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.record(z.string(), z.unknown()); 729 736 730 737 /** 731 738 * This is a free-form object with additionalProperties: {}. 732 739 */ 733 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.object({}); 740 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.record(z.string(), z.unknown()); 734 741 735 742 export const zModelWithConst = z.object({ 736 743 String: z.optional(z.enum([ ··· 1005 1012 preconditions: z.optional(zIoK8sApimachineryPkgApisMetaV1Preconditions) 1006 1013 }); 1007 1014 1008 - export const zAdditionalPropertiesUnknownIssue = z.object({}); 1015 + export const zAdditionalPropertiesUnknownIssue = z.record(z.string(), z.union([ 1016 + z.string(), 1017 + z.number() 1018 + ])); 1009 1019 1010 - export const zAdditionalPropertiesUnknownIssue2 = z.object({}); 1020 + export const zAdditionalPropertiesUnknownIssue2 = z.record(z.string(), z.union([ 1021 + z.string(), 1022 + z.number() 1023 + ])); 1011 1024 1012 1025 export const zAdditionalPropertiesUnknownIssue3 = z.intersection(z.string(), z.object({ 1013 - entries: z.object({}) 1026 + entries: z.record(z.string(), zAdditionalPropertiesUnknownIssue) 1014 1027 })); 1015 1028 1016 1029 export const zAdditionalPropertiesIntegerIssue = z.object({ ··· 1024 1037 z.null() 1025 1038 ])), 1026 1039 hasError: z.optional(z.boolean().readonly()), 1027 - data: z.optional(z.object({})) 1040 + data: z.optional(z.record(z.string(), z.never())) 1028 1041 }); 1029 1042 1030 1043 export const zGenericSchemaDuplicateIssue1SystemString = z.object({ ··· 1185 1198 /** 1186 1199 * This is a string dictionary 1187 1200 */ 1188 - export const zDictionaryWithStringWritable = z.object({}); 1201 + export const zDictionaryWithStringWritable = z.record(z.string(), z.string()); 1189 1202 1190 1203 /** 1191 1204 * This is a string dictionary 1192 1205 */ 1193 - export const zDictionaryWithDictionaryWritable = z.record(z.string(), z.object({})); 1206 + export const zDictionaryWithDictionaryWritable = z.record(z.string(), z.record(z.string(), z.string())); 1194 1207 1195 1208 /** 1196 1209 * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) ··· 1223 1236 /** 1224 1237 * This is a free-form object without additionalProperties. 1225 1238 */ 1226 - export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.object({}); 1239 + export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.record(z.string(), z.unknown()); 1227 1240 1228 1241 /** 1229 1242 * This is a free-form object with additionalProperties: true. 1230 1243 */ 1231 - export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.object({}); 1244 + export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.record(z.string(), z.unknown()); 1232 1245 1233 1246 /** 1234 1247 * This is a free-form object with additionalProperties: {}. 1235 1248 */ 1236 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.object({}); 1249 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.record(z.string(), z.unknown()); 1237 1250 1238 1251 /** 1239 1252 * Some % character ··· 1334 1347 */ 1335 1348 export const zDeleteFooData2Writable = z.string(); 1336 1349 1337 - export const zAdditionalPropertiesUnknownIssueWritable = z.object({}); 1350 + export const zAdditionalPropertiesUnknownIssueWritable = z.record(z.string(), z.union([ 1351 + z.string(), 1352 + z.number() 1353 + ])); 1338 1354 1339 - export const zAdditionalPropertiesUnknownIssue2Writable = z.object({}); 1355 + export const zAdditionalPropertiesUnknownIssue2Writable = z.record(z.string(), z.union([ 1356 + z.string(), 1357 + z.number() 1358 + ])); 1340 1359 1341 1360 export const zOneOfAllOfIssueWritable = z.union([ 1342 1361 z.intersection(z.union([ ··· 1492 1511 1493 1512 export const zCallWithParametersData = z.object({ 1494 1513 body: z.union([ 1495 - z.object({}), 1514 + z.record(z.string(), z.unknown()), 1496 1515 z.null() 1497 1516 ]), 1498 1517 path: z.object({ ··· 1800 1819 z.null() 1801 1820 ]).default(true), 1802 1821 parameterObject: z.union([ 1803 - z.object({}), 1822 + z.record(z.string(), z.unknown()), 1804 1823 z.null() 1805 1824 ]).default(null), 1806 1825 parameterArray: z.union([ ··· 1808 1827 z.null() 1809 1828 ]), 1810 1829 parameterDictionary: z.union([ 1811 - z.object({}), 1830 + z.record(z.string(), z.unknown()), 1812 1831 z.null() 1813 1832 ]), 1814 1833 parameterEnum: z.enum([ ··· 1823 1842 z.number(), 1824 1843 z.string(), 1825 1844 z.boolean(), 1826 - z.object({}) 1845 + z.record(z.string(), z.unknown()) 1827 1846 ]); 1828 1847 1829 1848 export const zUploadFileData = z.object({
+47 -28
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/default/zod.gen.ts
··· 203 203 /** 204 204 * This is a string dictionary 205 205 */ 206 - export const zDictionaryWithString = z.object({}); 206 + export const zDictionaryWithString = z.record(z.string(), z.string()); 207 207 208 208 export const zDictionaryWithPropertiesAndAdditionalProperties = z.object({ 209 209 foo: z.optional(z.number()), ··· 213 213 /** 214 214 * This is a string reference 215 215 */ 216 - export const zDictionaryWithReference = z.object({}); 216 + export const zDictionaryWithReference = z.record(z.string(), zModelWithString); 217 217 218 218 /** 219 219 * This is a complex dictionary 220 220 */ 221 - export const zDictionaryWithArray = z.object({}); 221 + export const zDictionaryWithArray = z.record(z.string(), z.array(zModelWithString)); 222 222 223 223 /** 224 224 * This is a string dictionary 225 225 */ 226 - export const zDictionaryWithDictionary = z.record(z.string(), z.object({})); 226 + export const zDictionaryWithDictionary = z.record(z.string(), z.record(z.string(), z.string())); 227 227 228 228 /** 229 229 * This is a complex dictionary ··· 328 328 * This is a model with nested enums 329 329 */ 330 330 export const zModelWithNestedEnums = z.object({ 331 - dictionaryWithEnum: z.optional(z.object({})), 332 - dictionaryWithEnumFromDescription: z.optional(z.object({})), 331 + dictionaryWithEnum: z.optional(z.record(z.string(), z.enum([ 332 + 'Success', 333 + 'Warning', 334 + 'Error' 335 + ]))), 336 + dictionaryWithEnumFromDescription: z.optional(z.record(z.string(), z.int())), 333 337 arrayWithEnum: z.optional(z.array(z.enum([ 334 338 'Success', 335 339 'Warning', ··· 399 403 * This is a model with one property containing a dictionary 400 404 */ 401 405 export const zModelWithDictionary = z.object({ 402 - prop: z.optional(z.object({})) 406 + prop: z.optional(z.record(z.string(), z.string())) 403 407 }); 404 408 405 409 /** ··· 556 560 export const zCompositionWithOneOfAndSimpleDictionary = z.object({ 557 561 propA: z.optional(z.union([ 558 562 z.boolean(), 559 - z.object({}) 563 + z.record(z.string(), z.number()) 560 564 ])) 561 565 }); 562 566 ··· 566 570 export const zCompositionWithOneOfAndSimpleArrayDictionary = z.object({ 567 571 propA: z.optional(z.union([ 568 572 z.boolean(), 569 - z.object({}) 573 + z.record(z.string(), z.array(z.boolean())) 570 574 ])) 571 575 }); 572 576 ··· 576 580 export const zCompositionWithOneOfAndComplexArrayDictionary = z.object({ 577 581 propA: z.optional(z.union([ 578 582 z.boolean(), 579 - z.object({}) 583 + z.record(z.string(), z.array(z.union([ 584 + z.number(), 585 + z.string() 586 + ]))) 580 587 ])) 581 588 }); 582 589 ··· 721 728 /** 722 729 * This is a free-form object without additionalProperties. 723 730 */ 724 - export const zFreeFormObjectWithoutAdditionalProperties = z.object({}); 731 + export const zFreeFormObjectWithoutAdditionalProperties = z.record(z.string(), z.unknown()); 725 732 726 733 /** 727 734 * This is a free-form object with additionalProperties: true. 728 735 */ 729 - export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.object({}); 736 + export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.record(z.string(), z.unknown()); 730 737 731 738 /** 732 739 * This is a free-form object with additionalProperties: {}. 733 740 */ 734 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.object({}); 741 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.record(z.string(), z.unknown()); 735 742 736 743 export const zModelWithConst = z.object({ 737 744 String: z.optional(z.literal('String')), ··· 1005 1012 preconditions: z.optional(zIoK8sApimachineryPkgApisMetaV1Preconditions) 1006 1013 }); 1007 1014 1008 - export const zAdditionalPropertiesUnknownIssue = z.object({}); 1015 + export const zAdditionalPropertiesUnknownIssue = z.record(z.string(), z.union([ 1016 + z.string(), 1017 + z.number() 1018 + ])); 1009 1019 1010 - export const zAdditionalPropertiesUnknownIssue2 = z.object({}); 1020 + export const zAdditionalPropertiesUnknownIssue2 = z.record(z.string(), z.union([ 1021 + z.string(), 1022 + z.number() 1023 + ])); 1011 1024 1012 1025 export const zAdditionalPropertiesUnknownIssue3 = z.intersection(z.string(), z.object({ 1013 - entries: z.object({}) 1026 + entries: z.record(z.string(), zAdditionalPropertiesUnknownIssue) 1014 1027 })); 1015 1028 1016 1029 export const zAdditionalPropertiesIntegerIssue = z.object({ ··· 1024 1037 z.null() 1025 1038 ])), 1026 1039 hasError: z.optional(z.readonly(z.boolean())), 1027 - data: z.optional(z.object({})) 1040 + data: z.optional(z.record(z.string(), z.never())) 1028 1041 }); 1029 1042 1030 1043 export const zGenericSchemaDuplicateIssue1SystemString = z.object({ ··· 1185 1198 /** 1186 1199 * This is a string dictionary 1187 1200 */ 1188 - export const zDictionaryWithStringWritable = z.object({}); 1201 + export const zDictionaryWithStringWritable = z.record(z.string(), z.string()); 1189 1202 1190 1203 /** 1191 1204 * This is a string dictionary 1192 1205 */ 1193 - export const zDictionaryWithDictionaryWritable = z.record(z.string(), z.object({})); 1206 + export const zDictionaryWithDictionaryWritable = z.record(z.string(), z.record(z.string(), z.string())); 1194 1207 1195 1208 /** 1196 1209 * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) ··· 1221 1234 /** 1222 1235 * This is a free-form object without additionalProperties. 1223 1236 */ 1224 - export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.object({}); 1237 + export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.record(z.string(), z.unknown()); 1225 1238 1226 1239 /** 1227 1240 * This is a free-form object with additionalProperties: true. 1228 1241 */ 1229 - export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.object({}); 1242 + export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.record(z.string(), z.unknown()); 1230 1243 1231 1244 /** 1232 1245 * This is a free-form object with additionalProperties: {}. 1233 1246 */ 1234 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.object({}); 1247 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.record(z.string(), z.unknown()); 1235 1248 1236 1249 /** 1237 1250 * Some % character ··· 1332 1345 */ 1333 1346 export const zDeleteFooData2Writable = z.string(); 1334 1347 1335 - export const zAdditionalPropertiesUnknownIssueWritable = z.object({}); 1348 + export const zAdditionalPropertiesUnknownIssueWritable = z.record(z.string(), z.union([ 1349 + z.string(), 1350 + z.number() 1351 + ])); 1336 1352 1337 - export const zAdditionalPropertiesUnknownIssue2Writable = z.object({}); 1353 + export const zAdditionalPropertiesUnknownIssue2Writable = z.record(z.string(), z.union([ 1354 + z.string(), 1355 + z.number() 1356 + ])); 1338 1357 1339 1358 export const zOneOfAllOfIssueWritable = z.union([ 1340 1359 z.intersection(z.union([ ··· 1499 1518 1500 1519 export const zCallWithParametersData = z.object({ 1501 1520 body: z.union([ 1502 - z.object({}), 1521 + z.record(z.string(), z.unknown()), 1503 1522 z.null() 1504 1523 ]), 1505 1524 path: z.object({ ··· 1807 1826 z.null() 1808 1827 ]), true), 1809 1828 parameterObject: z._default(z.union([ 1810 - z.object({}), 1829 + z.record(z.string(), z.unknown()), 1811 1830 z.null() 1812 1831 ]), null), 1813 1832 parameterArray: z.union([ ··· 1815 1834 z.null() 1816 1835 ]), 1817 1836 parameterDictionary: z.union([ 1818 - z.object({}), 1837 + z.record(z.string(), z.unknown()), 1819 1838 z.null() 1820 1839 ]), 1821 1840 parameterEnum: z.union([ ··· 1831 1850 z.number(), 1832 1851 z.string(), 1833 1852 z.boolean(), 1834 - z.object({}) 1853 + z.record(z.string(), z.unknown()) 1835 1854 ]); 1836 1855 1837 1856 export const zUploadFileData = z.object({
+1 -1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/schema-const/zod.gen.ts
··· 14 14 z.literal('foo'), 15 15 z.literal(true) 16 16 ])), 17 - corge: z.optional(z.object({})), 17 + corge: z.optional(z.record(z.string(), z.unknown())), 18 18 garply: z.optional(z.coerce.bigint()), 19 19 numberInt8: z.optional(z.literal(100)), 20 20 numberInt16: z.optional(z.literal(1000)),
+47 -28
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/default/zod.gen.ts
··· 203 203 /** 204 204 * This is a string dictionary 205 205 */ 206 - export const zDictionaryWithString = z.object({}); 206 + export const zDictionaryWithString = z.record(z.string()); 207 207 208 208 export const zDictionaryWithPropertiesAndAdditionalProperties = z.object({ 209 209 foo: z.number().optional(), ··· 213 213 /** 214 214 * This is a string reference 215 215 */ 216 - export const zDictionaryWithReference = z.object({}); 216 + export const zDictionaryWithReference = z.record(zModelWithString); 217 217 218 218 /** 219 219 * This is a complex dictionary 220 220 */ 221 - export const zDictionaryWithArray = z.object({}); 221 + export const zDictionaryWithArray = z.record(z.array(zModelWithString)); 222 222 223 223 /** 224 224 * This is a string dictionary 225 225 */ 226 - export const zDictionaryWithDictionary = z.record(z.object({})); 226 + export const zDictionaryWithDictionary = z.record(z.record(z.string())); 227 227 228 228 /** 229 229 * This is a complex dictionary ··· 328 328 * This is a model with nested enums 329 329 */ 330 330 export const zModelWithNestedEnums = z.object({ 331 - dictionaryWithEnum: z.object({}).optional(), 332 - dictionaryWithEnumFromDescription: z.object({}).optional(), 331 + dictionaryWithEnum: z.record(z.enum([ 332 + 'Success', 333 + 'Warning', 334 + 'Error' 335 + ])).optional(), 336 + dictionaryWithEnumFromDescription: z.record(z.number().int()).optional(), 333 337 arrayWithEnum: z.array(z.enum([ 334 338 'Success', 335 339 'Warning', ··· 399 403 * This is a model with one property containing a dictionary 400 404 */ 401 405 export const zModelWithDictionary = z.object({ 402 - prop: z.object({}).optional() 406 + prop: z.record(z.string()).optional() 403 407 }); 404 408 405 409 /** ··· 554 558 export const zCompositionWithOneOfAndSimpleDictionary = z.object({ 555 559 propA: z.union([ 556 560 z.boolean(), 557 - z.object({}) 561 + z.record(z.number()) 558 562 ]).optional() 559 563 }); 560 564 ··· 564 568 export const zCompositionWithOneOfAndSimpleArrayDictionary = z.object({ 565 569 propA: z.union([ 566 570 z.boolean(), 567 - z.object({}) 571 + z.record(z.array(z.boolean())) 568 572 ]).optional() 569 573 }); 570 574 ··· 574 578 export const zCompositionWithOneOfAndComplexArrayDictionary = z.object({ 575 579 propA: z.union([ 576 580 z.boolean(), 577 - z.object({}) 581 + z.record(z.array(z.union([ 582 + z.number(), 583 + z.string() 584 + ]))) 578 585 ]).optional() 579 586 }); 580 587 ··· 719 726 /** 720 727 * This is a free-form object without additionalProperties. 721 728 */ 722 - export const zFreeFormObjectWithoutAdditionalProperties = z.object({}); 729 + export const zFreeFormObjectWithoutAdditionalProperties = z.record(z.unknown()); 723 730 724 731 /** 725 732 * This is a free-form object with additionalProperties: true. 726 733 */ 727 - export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.object({}); 734 + export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.record(z.unknown()); 728 735 729 736 /** 730 737 * This is a free-form object with additionalProperties: {}. 731 738 */ 732 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.object({}); 739 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.record(z.unknown()); 733 740 734 741 export const zModelWithConst = z.object({ 735 742 String: z.literal('String').optional(), ··· 1003 1010 preconditions: zIoK8sApimachineryPkgApisMetaV1Preconditions.optional() 1004 1011 }); 1005 1012 1006 - export const zAdditionalPropertiesUnknownIssue = z.object({}); 1013 + export const zAdditionalPropertiesUnknownIssue = z.record(z.union([ 1014 + z.string(), 1015 + z.number() 1016 + ])); 1007 1017 1008 - export const zAdditionalPropertiesUnknownIssue2 = z.object({}); 1018 + export const zAdditionalPropertiesUnknownIssue2 = z.record(z.union([ 1019 + z.string(), 1020 + z.number() 1021 + ])); 1009 1022 1010 1023 export const zAdditionalPropertiesUnknownIssue3 = z.intersection(z.string(), z.object({ 1011 - entries: z.object({}) 1024 + entries: z.record(zAdditionalPropertiesUnknownIssue) 1012 1025 })); 1013 1026 1014 1027 export const zAdditionalPropertiesIntegerIssue = z.object({ ··· 1022 1035 z.null() 1023 1036 ]).optional(), 1024 1037 hasError: z.boolean().readonly().optional(), 1025 - data: z.object({}).optional() 1038 + data: z.record(z.never()).optional() 1026 1039 }); 1027 1040 1028 1041 export const zGenericSchemaDuplicateIssue1SystemString = z.object({ ··· 1183 1196 /** 1184 1197 * This is a string dictionary 1185 1198 */ 1186 - export const zDictionaryWithStringWritable = z.object({}); 1199 + export const zDictionaryWithStringWritable = z.record(z.string()); 1187 1200 1188 1201 /** 1189 1202 * This is a string dictionary 1190 1203 */ 1191 - export const zDictionaryWithDictionaryWritable = z.record(z.object({})); 1204 + export const zDictionaryWithDictionaryWritable = z.record(z.record(z.string())); 1192 1205 1193 1206 /** 1194 1207 * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) ··· 1219 1232 /** 1220 1233 * This is a free-form object without additionalProperties. 1221 1234 */ 1222 - export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.object({}); 1235 + export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.record(z.unknown()); 1223 1236 1224 1237 /** 1225 1238 * This is a free-form object with additionalProperties: true. 1226 1239 */ 1227 - export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.object({}); 1240 + export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.record(z.unknown()); 1228 1241 1229 1242 /** 1230 1243 * This is a free-form object with additionalProperties: {}. 1231 1244 */ 1232 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.object({}); 1245 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.record(z.unknown()); 1233 1246 1234 1247 /** 1235 1248 * Some % character ··· 1330 1343 */ 1331 1344 export const zDeleteFooData2Writable = z.string(); 1332 1345 1333 - export const zAdditionalPropertiesUnknownIssueWritable = z.object({}); 1346 + export const zAdditionalPropertiesUnknownIssueWritable = z.record(z.union([ 1347 + z.string(), 1348 + z.number() 1349 + ])); 1334 1350 1335 - export const zAdditionalPropertiesUnknownIssue2Writable = z.object({}); 1351 + export const zAdditionalPropertiesUnknownIssue2Writable = z.record(z.union([ 1352 + z.string(), 1353 + z.number() 1354 + ])); 1336 1355 1337 1356 export const zOneOfAllOfIssueWritable = z.union([ 1338 1357 z.intersection(z.union([ ··· 1497 1516 1498 1517 export const zCallWithParametersData = z.object({ 1499 1518 body: z.union([ 1500 - z.object({}), 1519 + z.record(z.unknown()), 1501 1520 z.null() 1502 1521 ]), 1503 1522 path: z.object({ ··· 1805 1824 z.null() 1806 1825 ]).default(true), 1807 1826 parameterObject: z.union([ 1808 - z.object({}), 1827 + z.record(z.unknown()), 1809 1828 z.null() 1810 1829 ]).default(null), 1811 1830 parameterArray: z.union([ ··· 1813 1832 z.null() 1814 1833 ]), 1815 1834 parameterDictionary: z.union([ 1816 - z.object({}), 1835 + z.record(z.unknown()), 1817 1836 z.null() 1818 1837 ]), 1819 1838 parameterEnum: z.union([ ··· 1829 1848 z.number(), 1830 1849 z.string(), 1831 1850 z.boolean(), 1832 - z.object({}) 1851 + z.record(z.unknown()) 1833 1852 ]); 1834 1853 1835 1854 export const zUploadFileData = z.object({
+1 -1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v3/schema-const/zod.gen.ts
··· 14 14 z.literal('foo'), 15 15 z.literal(true) 16 16 ]).optional(), 17 - corge: z.object({}).optional(), 17 + corge: z.record(z.unknown()).optional(), 18 18 garply: z.coerce.bigint().optional(), 19 19 numberInt8: z.literal(100).optional(), 20 20 numberInt16: z.literal(1000).optional(),
+47 -28
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/default/zod.gen.ts
··· 203 203 /** 204 204 * This is a string dictionary 205 205 */ 206 - export const zDictionaryWithString = z.object({}); 206 + export const zDictionaryWithString = z.record(z.string(), z.string()); 207 207 208 208 export const zDictionaryWithPropertiesAndAdditionalProperties = z.object({ 209 209 foo: z.optional(z.number()), ··· 213 213 /** 214 214 * This is a string reference 215 215 */ 216 - export const zDictionaryWithReference = z.object({}); 216 + export const zDictionaryWithReference = z.record(z.string(), zModelWithString); 217 217 218 218 /** 219 219 * This is a complex dictionary 220 220 */ 221 - export const zDictionaryWithArray = z.object({}); 221 + export const zDictionaryWithArray = z.record(z.string(), z.array(zModelWithString)); 222 222 223 223 /** 224 224 * This is a string dictionary 225 225 */ 226 - export const zDictionaryWithDictionary = z.record(z.string(), z.object({})); 226 + export const zDictionaryWithDictionary = z.record(z.string(), z.record(z.string(), z.string())); 227 227 228 228 /** 229 229 * This is a complex dictionary ··· 328 328 * This is a model with nested enums 329 329 */ 330 330 export const zModelWithNestedEnums = z.object({ 331 - dictionaryWithEnum: z.optional(z.object({})), 332 - dictionaryWithEnumFromDescription: z.optional(z.object({})), 331 + dictionaryWithEnum: z.optional(z.record(z.string(), z.enum([ 332 + 'Success', 333 + 'Warning', 334 + 'Error' 335 + ]))), 336 + dictionaryWithEnumFromDescription: z.optional(z.record(z.string(), z.int())), 333 337 arrayWithEnum: z.optional(z.array(z.enum([ 334 338 'Success', 335 339 'Warning', ··· 399 403 * This is a model with one property containing a dictionary 400 404 */ 401 405 export const zModelWithDictionary = z.object({ 402 - prop: z.optional(z.object({})) 406 + prop: z.optional(z.record(z.string(), z.string())) 403 407 }); 404 408 405 409 /** ··· 556 560 export const zCompositionWithOneOfAndSimpleDictionary = z.object({ 557 561 propA: z.optional(z.union([ 558 562 z.boolean(), 559 - z.object({}) 563 + z.record(z.string(), z.number()) 560 564 ])) 561 565 }); 562 566 ··· 566 570 export const zCompositionWithOneOfAndSimpleArrayDictionary = z.object({ 567 571 propA: z.optional(z.union([ 568 572 z.boolean(), 569 - z.object({}) 573 + z.record(z.string(), z.array(z.boolean())) 570 574 ])) 571 575 }); 572 576 ··· 576 580 export const zCompositionWithOneOfAndComplexArrayDictionary = z.object({ 577 581 propA: z.optional(z.union([ 578 582 z.boolean(), 579 - z.object({}) 583 + z.record(z.string(), z.array(z.union([ 584 + z.number(), 585 + z.string() 586 + ]))) 580 587 ])) 581 588 }); 582 589 ··· 721 728 /** 722 729 * This is a free-form object without additionalProperties. 723 730 */ 724 - export const zFreeFormObjectWithoutAdditionalProperties = z.object({}); 731 + export const zFreeFormObjectWithoutAdditionalProperties = z.record(z.string(), z.unknown()); 725 732 726 733 /** 727 734 * This is a free-form object with additionalProperties: true. 728 735 */ 729 - export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.object({}); 736 + export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.record(z.string(), z.unknown()); 730 737 731 738 /** 732 739 * This is a free-form object with additionalProperties: {}. 733 740 */ 734 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.object({}); 741 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.record(z.string(), z.unknown()); 735 742 736 743 export const zModelWithConst = z.object({ 737 744 String: z.optional(z.literal('String')), ··· 1005 1012 preconditions: z.optional(zIoK8sApimachineryPkgApisMetaV1Preconditions) 1006 1013 }); 1007 1014 1008 - export const zAdditionalPropertiesUnknownIssue = z.object({}); 1015 + export const zAdditionalPropertiesUnknownIssue = z.record(z.string(), z.union([ 1016 + z.string(), 1017 + z.number() 1018 + ])); 1009 1019 1010 - export const zAdditionalPropertiesUnknownIssue2 = z.object({}); 1020 + export const zAdditionalPropertiesUnknownIssue2 = z.record(z.string(), z.union([ 1021 + z.string(), 1022 + z.number() 1023 + ])); 1011 1024 1012 1025 export const zAdditionalPropertiesUnknownIssue3 = z.intersection(z.string(), z.object({ 1013 - entries: z.object({}) 1026 + entries: z.record(z.string(), zAdditionalPropertiesUnknownIssue) 1014 1027 })); 1015 1028 1016 1029 export const zAdditionalPropertiesIntegerIssue = z.object({ ··· 1024 1037 z.null() 1025 1038 ])), 1026 1039 hasError: z.optional(z.boolean().readonly()), 1027 - data: z.optional(z.object({})) 1040 + data: z.optional(z.record(z.string(), z.never())) 1028 1041 }); 1029 1042 1030 1043 export const zGenericSchemaDuplicateIssue1SystemString = z.object({ ··· 1185 1198 /** 1186 1199 * This is a string dictionary 1187 1200 */ 1188 - export const zDictionaryWithStringWritable = z.object({}); 1201 + export const zDictionaryWithStringWritable = z.record(z.string(), z.string()); 1189 1202 1190 1203 /** 1191 1204 * This is a string dictionary 1192 1205 */ 1193 - export const zDictionaryWithDictionaryWritable = z.record(z.string(), z.object({})); 1206 + export const zDictionaryWithDictionaryWritable = z.record(z.string(), z.record(z.string(), z.string())); 1194 1207 1195 1208 /** 1196 1209 * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) ··· 1221 1234 /** 1222 1235 * This is a free-form object without additionalProperties. 1223 1236 */ 1224 - export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.object({}); 1237 + export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.record(z.string(), z.unknown()); 1225 1238 1226 1239 /** 1227 1240 * This is a free-form object with additionalProperties: true. 1228 1241 */ 1229 - export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.object({}); 1242 + export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.record(z.string(), z.unknown()); 1230 1243 1231 1244 /** 1232 1245 * This is a free-form object with additionalProperties: {}. 1233 1246 */ 1234 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.object({}); 1247 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.record(z.string(), z.unknown()); 1235 1248 1236 1249 /** 1237 1250 * Some % character ··· 1332 1345 */ 1333 1346 export const zDeleteFooData2Writable = z.string(); 1334 1347 1335 - export const zAdditionalPropertiesUnknownIssueWritable = z.object({}); 1348 + export const zAdditionalPropertiesUnknownIssueWritable = z.record(z.string(), z.union([ 1349 + z.string(), 1350 + z.number() 1351 + ])); 1336 1352 1337 - export const zAdditionalPropertiesUnknownIssue2Writable = z.object({}); 1353 + export const zAdditionalPropertiesUnknownIssue2Writable = z.record(z.string(), z.union([ 1354 + z.string(), 1355 + z.number() 1356 + ])); 1338 1357 1339 1358 export const zOneOfAllOfIssueWritable = z.union([ 1340 1359 z.intersection(z.union([ ··· 1499 1518 1500 1519 export const zCallWithParametersData = z.object({ 1501 1520 body: z.union([ 1502 - z.object({}), 1521 + z.record(z.string(), z.unknown()), 1503 1522 z.null() 1504 1523 ]), 1505 1524 path: z.object({ ··· 1807 1826 z.null() 1808 1827 ]).default(true), 1809 1828 parameterObject: z.union([ 1810 - z.object({}), 1829 + z.record(z.string(), z.unknown()), 1811 1830 z.null() 1812 1831 ]).default(null), 1813 1832 parameterArray: z.union([ ··· 1815 1834 z.null() 1816 1835 ]), 1817 1836 parameterDictionary: z.union([ 1818 - z.object({}), 1837 + z.record(z.string(), z.unknown()), 1819 1838 z.null() 1820 1839 ]), 1821 1840 parameterEnum: z.union([ ··· 1831 1850 z.number(), 1832 1851 z.string(), 1833 1852 z.boolean(), 1834 - z.object({}) 1853 + z.record(z.string(), z.unknown()) 1835 1854 ]); 1836 1855 1837 1856 export const zUploadFileData = z.object({
+1 -1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/schema-const/zod.gen.ts
··· 14 14 z.literal('foo'), 15 15 z.literal(true) 16 16 ])), 17 - corge: z.optional(z.object({})), 17 + corge: z.optional(z.record(z.string(), z.unknown())), 18 18 garply: z.optional(z.coerce.bigint()), 19 19 numberInt8: z.optional(z.literal(100)), 20 20 numberInt16: z.optional(z.literal(1000)),
+13 -9
packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/mini/default/zod.gen.ts
··· 142 142 /** 143 143 * This is a string dictionary 144 144 */ 145 - export const zDictionaryWithString = z.object({}); 145 + export const zDictionaryWithString = z.record(z.string(), z.string()); 146 146 147 147 /** 148 148 * This is a string reference 149 149 */ 150 - export const zDictionaryWithReference = z.object({}); 150 + export const zDictionaryWithReference = z.record(z.string(), zModelWithString); 151 151 152 152 /** 153 153 * This is a complex dictionary 154 154 */ 155 - export const zDictionaryWithArray = z.object({}); 155 + export const zDictionaryWithArray = z.record(z.string(), z.array(zModelWithString)); 156 156 157 157 /** 158 158 * This is a string dictionary 159 159 */ 160 - export const zDictionaryWithDictionary = z.record(z.string(), z.object({})); 160 + export const zDictionaryWithDictionary = z.record(z.string(), z.record(z.string(), z.string())); 161 161 162 162 /** 163 163 * This is a complex dictionary ··· 239 239 * This is a model with nested enums 240 240 */ 241 241 export const zModelWithNestedEnums = z.object({ 242 - dictionaryWithEnum: z.optional(z.object({})), 243 - dictionaryWithEnumFromDescription: z.optional(z.object({})), 242 + dictionaryWithEnum: z.optional(z.record(z.string(), z.enum([ 243 + 'Success', 244 + 'Warning', 245 + 'Error' 246 + ]))), 247 + dictionaryWithEnumFromDescription: z.optional(z.record(z.string(), z.int())), 244 248 arrayWithEnum: z.optional(z.array(z.enum([ 245 249 'Success', 246 250 'Warning', ··· 286 290 * This is a model with one property containing a dictionary 287 291 */ 288 292 export const zModelWithDictionary = z.object({ 289 - prop: z.optional(z.object({})) 293 + prop: z.optional(z.record(z.string(), z.string())) 290 294 }); 291 295 292 296 /** ··· 666 670 parameterString: z._default(z.string(), 'default'), 667 671 parameterBoolean: z._default(z.boolean(), true), 668 672 parameterArray: z.array(z.string()), 669 - parameterDictionary: z.object({}), 673 + parameterDictionary: z.record(z.string(), z.unknown()), 670 674 parameterEnum: z.enum([ 671 675 'Success', 672 676 'Warning', ··· 679 683 z.number(), 680 684 z.string(), 681 685 z.boolean(), 682 - z.object({}) 686 + z.record(z.string(), z.unknown()) 683 687 ]); 684 688 685 689 export const zComplexTypesData = z.object({
+13 -9
packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v3/default/zod.gen.ts
··· 142 142 /** 143 143 * This is a string dictionary 144 144 */ 145 - export const zDictionaryWithString = z.object({}); 145 + export const zDictionaryWithString = z.record(z.string()); 146 146 147 147 /** 148 148 * This is a string reference 149 149 */ 150 - export const zDictionaryWithReference = z.object({}); 150 + export const zDictionaryWithReference = z.record(zModelWithString); 151 151 152 152 /** 153 153 * This is a complex dictionary 154 154 */ 155 - export const zDictionaryWithArray = z.object({}); 155 + export const zDictionaryWithArray = z.record(z.array(zModelWithString)); 156 156 157 157 /** 158 158 * This is a string dictionary 159 159 */ 160 - export const zDictionaryWithDictionary = z.record(z.object({})); 160 + export const zDictionaryWithDictionary = z.record(z.record(z.string())); 161 161 162 162 /** 163 163 * This is a complex dictionary ··· 239 239 * This is a model with nested enums 240 240 */ 241 241 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(), 244 248 arrayWithEnum: z.array(z.enum([ 245 249 'Success', 246 250 'Warning', ··· 286 290 * This is a model with one property containing a dictionary 287 291 */ 288 292 export const zModelWithDictionary = z.object({ 289 - prop: z.object({}).optional() 293 + prop: z.record(z.string()).optional() 290 294 }); 291 295 292 296 /** ··· 664 668 parameterString: z.string().default('default'), 665 669 parameterBoolean: z.boolean().default(true), 666 670 parameterArray: z.array(z.string()), 667 - parameterDictionary: z.object({}), 671 + parameterDictionary: z.record(z.unknown()), 668 672 parameterEnum: z.enum([ 669 673 'Success', 670 674 'Warning', ··· 677 681 z.number(), 678 682 z.string(), 679 683 z.boolean(), 680 - z.object({}) 684 + z.record(z.unknown()) 681 685 ]); 682 686 683 687 export const zComplexTypesData = z.object({
+13 -9
packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v4/default/zod.gen.ts
··· 142 142 /** 143 143 * This is a string dictionary 144 144 */ 145 - export const zDictionaryWithString = z.object({}); 145 + export const zDictionaryWithString = z.record(z.string(), z.string()); 146 146 147 147 /** 148 148 * This is a string reference 149 149 */ 150 - export const zDictionaryWithReference = z.object({}); 150 + export const zDictionaryWithReference = z.record(z.string(), zModelWithString); 151 151 152 152 /** 153 153 * This is a complex dictionary 154 154 */ 155 - export const zDictionaryWithArray = z.object({}); 155 + export const zDictionaryWithArray = z.record(z.string(), z.array(zModelWithString)); 156 156 157 157 /** 158 158 * This is a string dictionary 159 159 */ 160 - export const zDictionaryWithDictionary = z.record(z.string(), z.object({})); 160 + export const zDictionaryWithDictionary = z.record(z.string(), z.record(z.string(), z.string())); 161 161 162 162 /** 163 163 * This is a complex dictionary ··· 239 239 * This is a model with nested enums 240 240 */ 241 241 export const zModelWithNestedEnums = z.object({ 242 - dictionaryWithEnum: z.optional(z.object({})), 243 - dictionaryWithEnumFromDescription: z.optional(z.object({})), 242 + dictionaryWithEnum: z.optional(z.record(z.string(), z.enum([ 243 + 'Success', 244 + 'Warning', 245 + 'Error' 246 + ]))), 247 + dictionaryWithEnumFromDescription: z.optional(z.record(z.string(), z.int())), 244 248 arrayWithEnum: z.optional(z.array(z.enum([ 245 249 'Success', 246 250 'Warning', ··· 286 290 * This is a model with one property containing a dictionary 287 291 */ 288 292 export const zModelWithDictionary = z.object({ 289 - prop: z.optional(z.object({})) 293 + prop: z.optional(z.record(z.string(), z.string())) 290 294 }); 291 295 292 296 /** ··· 666 670 parameterString: z.string().default('default'), 667 671 parameterBoolean: z.boolean().default(true), 668 672 parameterArray: z.array(z.string()), 669 - parameterDictionary: z.object({}), 673 + parameterDictionary: z.record(z.string(), z.unknown()), 670 674 parameterEnum: z.enum([ 671 675 'Success', 672 676 'Warning', ··· 679 683 z.number(), 680 684 z.string(), 681 685 z.boolean(), 682 - z.object({}) 686 + z.record(z.string(), z.unknown()) 683 687 ]); 684 688 685 689 export const zComplexTypesData = z.object({
+47 -28
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/default/zod.gen.ts
··· 200 200 /** 201 201 * This is a string dictionary 202 202 */ 203 - export const zDictionaryWithString = z.object({}); 203 + export const zDictionaryWithString = z.record(z.string(), z.string()); 204 204 205 205 export const zDictionaryWithPropertiesAndAdditionalProperties = z.object({ 206 206 foo: z.optional(z.number()), ··· 210 210 /** 211 211 * This is a string reference 212 212 */ 213 - export const zDictionaryWithReference = z.object({}); 213 + export const zDictionaryWithReference = z.record(z.string(), zModelWithString); 214 214 215 215 /** 216 216 * This is a complex dictionary 217 217 */ 218 - export const zDictionaryWithArray = z.object({}); 218 + export const zDictionaryWithArray = z.record(z.string(), z.array(zModelWithString)); 219 219 220 220 /** 221 221 * This is a string dictionary 222 222 */ 223 - export const zDictionaryWithDictionary = z.record(z.string(), z.object({})); 223 + export const zDictionaryWithDictionary = z.record(z.string(), z.record(z.string(), z.string())); 224 224 225 225 /** 226 226 * This is a complex dictionary ··· 325 325 * This is a model with nested enums 326 326 */ 327 327 export const zModelWithNestedEnums = z.object({ 328 - dictionaryWithEnum: z.optional(z.object({})), 329 - dictionaryWithEnumFromDescription: z.optional(z.object({})), 328 + dictionaryWithEnum: z.optional(z.record(z.string(), z.enum([ 329 + 'Success', 330 + 'Warning', 331 + 'Error' 332 + ]))), 333 + dictionaryWithEnumFromDescription: z.optional(z.record(z.string(), z.int())), 330 334 arrayWithEnum: z.optional(z.array(z.enum([ 331 335 'Success', 332 336 'Warning', ··· 396 400 * This is a model with one property containing a dictionary 397 401 */ 398 402 export const zModelWithDictionary = z.object({ 399 - prop: z.optional(z.object({})) 403 + prop: z.optional(z.record(z.string(), z.string())) 400 404 }); 401 405 402 406 /** ··· 555 559 export const zCompositionWithOneOfAndSimpleDictionary = z.object({ 556 560 propA: z.optional(z.union([ 557 561 z.boolean(), 558 - z.object({}) 562 + z.record(z.string(), z.number()) 559 563 ])) 560 564 }); 561 565 ··· 565 569 export const zCompositionWithOneOfAndSimpleArrayDictionary = z.object({ 566 570 propA: z.optional(z.union([ 567 571 z.boolean(), 568 - z.object({}) 572 + z.record(z.string(), z.array(z.boolean())) 569 573 ])) 570 574 }); 571 575 ··· 575 579 export const zCompositionWithOneOfAndComplexArrayDictionary = z.object({ 576 580 propA: z.optional(z.union([ 577 581 z.boolean(), 578 - z.object({}) 582 + z.record(z.string(), z.array(z.union([ 583 + z.number(), 584 + z.string() 585 + ]))) 579 586 ])) 580 587 }); 581 588 ··· 720 727 /** 721 728 * This is a free-form object without additionalProperties. 722 729 */ 723 - export const zFreeFormObjectWithoutAdditionalProperties = z.object({}); 730 + export const zFreeFormObjectWithoutAdditionalProperties = z.record(z.string(), z.unknown()); 724 731 725 732 /** 726 733 * This is a free-form object with additionalProperties: true. 727 734 */ 728 - export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.object({}); 735 + export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.record(z.string(), z.unknown()); 729 736 730 737 /** 731 738 * This is a free-form object with additionalProperties: {}. 732 739 */ 733 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.object({}); 740 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.record(z.string(), z.unknown()); 734 741 735 742 export const zModelWithConst = z.object({ 736 743 String: z.optional(z.enum([ ··· 1005 1012 preconditions: z.optional(zIoK8sApimachineryPkgApisMetaV1Preconditions) 1006 1013 }); 1007 1014 1008 - export const zAdditionalPropertiesUnknownIssue = z.object({}); 1015 + export const zAdditionalPropertiesUnknownIssue = z.record(z.string(), z.union([ 1016 + z.string(), 1017 + z.number() 1018 + ])); 1009 1019 1010 - export const zAdditionalPropertiesUnknownIssue2 = z.object({}); 1020 + export const zAdditionalPropertiesUnknownIssue2 = z.record(z.string(), z.union([ 1021 + z.string(), 1022 + z.number() 1023 + ])); 1011 1024 1012 1025 export const zAdditionalPropertiesUnknownIssue3 = z.intersection(z.string(), z.object({ 1013 - entries: z.object({}) 1026 + entries: z.record(z.string(), zAdditionalPropertiesUnknownIssue) 1014 1027 })); 1015 1028 1016 1029 export const zAdditionalPropertiesIntegerIssue = z.object({ ··· 1024 1037 z.null() 1025 1038 ])), 1026 1039 hasError: z.optional(z.readonly(z.boolean())), 1027 - data: z.optional(z.object({})) 1040 + data: z.optional(z.record(z.string(), z.never())) 1028 1041 }); 1029 1042 1030 1043 export const zGenericSchemaDuplicateIssue1SystemString = z.object({ ··· 1185 1198 /** 1186 1199 * This is a string dictionary 1187 1200 */ 1188 - export const zDictionaryWithStringWritable = z.object({}); 1201 + export const zDictionaryWithStringWritable = z.record(z.string(), z.string()); 1189 1202 1190 1203 /** 1191 1204 * This is a string dictionary 1192 1205 */ 1193 - export const zDictionaryWithDictionaryWritable = z.record(z.string(), z.object({})); 1206 + export const zDictionaryWithDictionaryWritable = z.record(z.string(), z.record(z.string(), z.string())); 1194 1207 1195 1208 /** 1196 1209 * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) ··· 1223 1236 /** 1224 1237 * This is a free-form object without additionalProperties. 1225 1238 */ 1226 - export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.object({}); 1239 + export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.record(z.string(), z.unknown()); 1227 1240 1228 1241 /** 1229 1242 * This is a free-form object with additionalProperties: true. 1230 1243 */ 1231 - export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.object({}); 1244 + export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.record(z.string(), z.unknown()); 1232 1245 1233 1246 /** 1234 1247 * This is a free-form object with additionalProperties: {}. 1235 1248 */ 1236 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.object({}); 1249 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.record(z.string(), z.unknown()); 1237 1250 1238 1251 /** 1239 1252 * Some % character ··· 1334 1347 */ 1335 1348 export const zDeleteFooData2Writable = z.string(); 1336 1349 1337 - export const zAdditionalPropertiesUnknownIssueWritable = z.object({}); 1350 + export const zAdditionalPropertiesUnknownIssueWritable = z.record(z.string(), z.union([ 1351 + z.string(), 1352 + z.number() 1353 + ])); 1338 1354 1339 - export const zAdditionalPropertiesUnknownIssue2Writable = z.object({}); 1355 + export const zAdditionalPropertiesUnknownIssue2Writable = z.record(z.string(), z.union([ 1356 + z.string(), 1357 + z.number() 1358 + ])); 1340 1359 1341 1360 export const zOneOfAllOfIssueWritable = z.union([ 1342 1361 z.intersection(z.union([ ··· 1492 1511 1493 1512 export const zCallWithParametersData = z.object({ 1494 1513 body: z.union([ 1495 - z.object({}), 1514 + z.record(z.string(), z.unknown()), 1496 1515 z.null() 1497 1516 ]), 1498 1517 path: z.object({ ··· 1800 1819 z.null() 1801 1820 ]), true), 1802 1821 parameterObject: z._default(z.union([ 1803 - z.object({}), 1822 + z.record(z.string(), z.unknown()), 1804 1823 z.null() 1805 1824 ]), null), 1806 1825 parameterArray: z.union([ ··· 1808 1827 z.null() 1809 1828 ]), 1810 1829 parameterDictionary: z.union([ 1811 - z.object({}), 1830 + z.record(z.string(), z.unknown()), 1812 1831 z.null() 1813 1832 ]), 1814 1833 parameterEnum: z.enum([ ··· 1823 1842 z.number(), 1824 1843 z.string(), 1825 1844 z.boolean(), 1826 - z.object({}) 1845 + z.record(z.string(), z.unknown()) 1827 1846 ]); 1828 1847 1829 1848 export const zUploadFileData = z.object({
+47 -28
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/default/zod.gen.ts
··· 200 200 /** 201 201 * This is a string dictionary 202 202 */ 203 - export const zDictionaryWithString = z.object({}); 203 + export const zDictionaryWithString = z.record(z.string()); 204 204 205 205 export const zDictionaryWithPropertiesAndAdditionalProperties = z.object({ 206 206 foo: z.number().optional(), ··· 210 210 /** 211 211 * This is a string reference 212 212 */ 213 - export const zDictionaryWithReference = z.object({}); 213 + export const zDictionaryWithReference = z.record(zModelWithString); 214 214 215 215 /** 216 216 * This is a complex dictionary 217 217 */ 218 - export const zDictionaryWithArray = z.object({}); 218 + export const zDictionaryWithArray = z.record(z.array(zModelWithString)); 219 219 220 220 /** 221 221 * This is a string dictionary 222 222 */ 223 - export const zDictionaryWithDictionary = z.record(z.object({})); 223 + export const zDictionaryWithDictionary = z.record(z.record(z.string())); 224 224 225 225 /** 226 226 * This is a complex dictionary ··· 325 325 * This is a model with nested enums 326 326 */ 327 327 export const zModelWithNestedEnums = z.object({ 328 - dictionaryWithEnum: z.object({}).optional(), 329 - dictionaryWithEnumFromDescription: z.object({}).optional(), 328 + dictionaryWithEnum: z.record(z.enum([ 329 + 'Success', 330 + 'Warning', 331 + 'Error' 332 + ])).optional(), 333 + dictionaryWithEnumFromDescription: z.record(z.number().int()).optional(), 330 334 arrayWithEnum: z.array(z.enum([ 331 335 'Success', 332 336 'Warning', ··· 396 400 * This is a model with one property containing a dictionary 397 401 */ 398 402 export const zModelWithDictionary = z.object({ 399 - prop: z.object({}).optional() 403 + prop: z.record(z.string()).optional() 400 404 }); 401 405 402 406 /** ··· 553 557 export const zCompositionWithOneOfAndSimpleDictionary = z.object({ 554 558 propA: z.union([ 555 559 z.boolean(), 556 - z.object({}) 560 + z.record(z.number()) 557 561 ]).optional() 558 562 }); 559 563 ··· 563 567 export const zCompositionWithOneOfAndSimpleArrayDictionary = z.object({ 564 568 propA: z.union([ 565 569 z.boolean(), 566 - z.object({}) 570 + z.record(z.array(z.boolean())) 567 571 ]).optional() 568 572 }); 569 573 ··· 573 577 export const zCompositionWithOneOfAndComplexArrayDictionary = z.object({ 574 578 propA: z.union([ 575 579 z.boolean(), 576 - z.object({}) 580 + z.record(z.array(z.union([ 581 + z.number(), 582 + z.string() 583 + ]))) 577 584 ]).optional() 578 585 }); 579 586 ··· 718 725 /** 719 726 * This is a free-form object without additionalProperties. 720 727 */ 721 - export const zFreeFormObjectWithoutAdditionalProperties = z.object({}); 728 + export const zFreeFormObjectWithoutAdditionalProperties = z.record(z.unknown()); 722 729 723 730 /** 724 731 * This is a free-form object with additionalProperties: true. 725 732 */ 726 - export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.object({}); 733 + export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.record(z.unknown()); 727 734 728 735 /** 729 736 * This is a free-form object with additionalProperties: {}. 730 737 */ 731 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.object({}); 738 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.record(z.unknown()); 732 739 733 740 export const zModelWithConst = z.object({ 734 741 String: z.enum([ ··· 1003 1010 preconditions: zIoK8sApimachineryPkgApisMetaV1Preconditions.optional() 1004 1011 }); 1005 1012 1006 - export const zAdditionalPropertiesUnknownIssue = z.object({}); 1013 + export const zAdditionalPropertiesUnknownIssue = z.record(z.union([ 1014 + z.string(), 1015 + z.number() 1016 + ])); 1007 1017 1008 - export const zAdditionalPropertiesUnknownIssue2 = z.object({}); 1018 + export const zAdditionalPropertiesUnknownIssue2 = z.record(z.union([ 1019 + z.string(), 1020 + z.number() 1021 + ])); 1009 1022 1010 1023 export const zAdditionalPropertiesUnknownIssue3 = z.intersection(z.string(), z.object({ 1011 - entries: z.object({}) 1024 + entries: z.record(zAdditionalPropertiesUnknownIssue) 1012 1025 })); 1013 1026 1014 1027 export const zAdditionalPropertiesIntegerIssue = z.object({ ··· 1022 1035 z.null() 1023 1036 ]).optional(), 1024 1037 hasError: z.boolean().readonly().optional(), 1025 - data: z.object({}).optional() 1038 + data: z.record(z.never()).optional() 1026 1039 }); 1027 1040 1028 1041 export const zGenericSchemaDuplicateIssue1SystemString = z.object({ ··· 1183 1196 /** 1184 1197 * This is a string dictionary 1185 1198 */ 1186 - export const zDictionaryWithStringWritable = z.object({}); 1199 + export const zDictionaryWithStringWritable = z.record(z.string()); 1187 1200 1188 1201 /** 1189 1202 * This is a string dictionary 1190 1203 */ 1191 - export const zDictionaryWithDictionaryWritable = z.record(z.object({})); 1204 + export const zDictionaryWithDictionaryWritable = z.record(z.record(z.string())); 1192 1205 1193 1206 /** 1194 1207 * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) ··· 1221 1234 /** 1222 1235 * This is a free-form object without additionalProperties. 1223 1236 */ 1224 - export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.object({}); 1237 + export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.record(z.unknown()); 1225 1238 1226 1239 /** 1227 1240 * This is a free-form object with additionalProperties: true. 1228 1241 */ 1229 - export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.object({}); 1242 + export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.record(z.unknown()); 1230 1243 1231 1244 /** 1232 1245 * This is a free-form object with additionalProperties: {}. 1233 1246 */ 1234 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.object({}); 1247 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.record(z.unknown()); 1235 1248 1236 1249 /** 1237 1250 * Some % character ··· 1332 1345 */ 1333 1346 export const zDeleteFooData2Writable = z.string(); 1334 1347 1335 - export const zAdditionalPropertiesUnknownIssueWritable = z.object({}); 1348 + export const zAdditionalPropertiesUnknownIssueWritable = z.record(z.union([ 1349 + z.string(), 1350 + z.number() 1351 + ])); 1336 1352 1337 - export const zAdditionalPropertiesUnknownIssue2Writable = z.object({}); 1353 + export const zAdditionalPropertiesUnknownIssue2Writable = z.record(z.union([ 1354 + z.string(), 1355 + z.number() 1356 + ])); 1338 1357 1339 1358 export const zOneOfAllOfIssueWritable = z.union([ 1340 1359 z.intersection(z.union([ ··· 1490 1509 1491 1510 export const zCallWithParametersData = z.object({ 1492 1511 body: z.union([ 1493 - z.object({}), 1512 + z.record(z.unknown()), 1494 1513 z.null() 1495 1514 ]), 1496 1515 path: z.object({ ··· 1798 1817 z.null() 1799 1818 ]).default(true), 1800 1819 parameterObject: z.union([ 1801 - z.object({}), 1820 + z.record(z.unknown()), 1802 1821 z.null() 1803 1822 ]).default(null), 1804 1823 parameterArray: z.union([ ··· 1806 1825 z.null() 1807 1826 ]), 1808 1827 parameterDictionary: z.union([ 1809 - z.object({}), 1828 + z.record(z.unknown()), 1810 1829 z.null() 1811 1830 ]), 1812 1831 parameterEnum: z.enum([ ··· 1821 1840 z.number(), 1822 1841 z.string(), 1823 1842 z.boolean(), 1824 - z.object({}) 1843 + z.record(z.unknown()) 1825 1844 ]); 1826 1845 1827 1846 export const zUploadFileData = z.object({
+47 -28
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/default/zod.gen.ts
··· 200 200 /** 201 201 * This is a string dictionary 202 202 */ 203 - export const zDictionaryWithString = z.object({}); 203 + export const zDictionaryWithString = z.record(z.string(), z.string()); 204 204 205 205 export const zDictionaryWithPropertiesAndAdditionalProperties = z.object({ 206 206 foo: z.optional(z.number()), ··· 210 210 /** 211 211 * This is a string reference 212 212 */ 213 - export const zDictionaryWithReference = z.object({}); 213 + export const zDictionaryWithReference = z.record(z.string(), zModelWithString); 214 214 215 215 /** 216 216 * This is a complex dictionary 217 217 */ 218 - export const zDictionaryWithArray = z.object({}); 218 + export const zDictionaryWithArray = z.record(z.string(), z.array(zModelWithString)); 219 219 220 220 /** 221 221 * This is a string dictionary 222 222 */ 223 - export const zDictionaryWithDictionary = z.record(z.string(), z.object({})); 223 + export const zDictionaryWithDictionary = z.record(z.string(), z.record(z.string(), z.string())); 224 224 225 225 /** 226 226 * This is a complex dictionary ··· 325 325 * This is a model with nested enums 326 326 */ 327 327 export const zModelWithNestedEnums = z.object({ 328 - dictionaryWithEnum: z.optional(z.object({})), 329 - dictionaryWithEnumFromDescription: z.optional(z.object({})), 328 + dictionaryWithEnum: z.optional(z.record(z.string(), z.enum([ 329 + 'Success', 330 + 'Warning', 331 + 'Error' 332 + ]))), 333 + dictionaryWithEnumFromDescription: z.optional(z.record(z.string(), z.int())), 330 334 arrayWithEnum: z.optional(z.array(z.enum([ 331 335 'Success', 332 336 'Warning', ··· 396 400 * This is a model with one property containing a dictionary 397 401 */ 398 402 export const zModelWithDictionary = z.object({ 399 - prop: z.optional(z.object({})) 403 + prop: z.optional(z.record(z.string(), z.string())) 400 404 }); 401 405 402 406 /** ··· 555 559 export const zCompositionWithOneOfAndSimpleDictionary = z.object({ 556 560 propA: z.optional(z.union([ 557 561 z.boolean(), 558 - z.object({}) 562 + z.record(z.string(), z.number()) 559 563 ])) 560 564 }); 561 565 ··· 565 569 export const zCompositionWithOneOfAndSimpleArrayDictionary = z.object({ 566 570 propA: z.optional(z.union([ 567 571 z.boolean(), 568 - z.object({}) 572 + z.record(z.string(), z.array(z.boolean())) 569 573 ])) 570 574 }); 571 575 ··· 575 579 export const zCompositionWithOneOfAndComplexArrayDictionary = z.object({ 576 580 propA: z.optional(z.union([ 577 581 z.boolean(), 578 - z.object({}) 582 + z.record(z.string(), z.array(z.union([ 583 + z.number(), 584 + z.string() 585 + ]))) 579 586 ])) 580 587 }); 581 588 ··· 720 727 /** 721 728 * This is a free-form object without additionalProperties. 722 729 */ 723 - export const zFreeFormObjectWithoutAdditionalProperties = z.object({}); 730 + export const zFreeFormObjectWithoutAdditionalProperties = z.record(z.string(), z.unknown()); 724 731 725 732 /** 726 733 * This is a free-form object with additionalProperties: true. 727 734 */ 728 - export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.object({}); 735 + export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.record(z.string(), z.unknown()); 729 736 730 737 /** 731 738 * This is a free-form object with additionalProperties: {}. 732 739 */ 733 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.object({}); 740 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.record(z.string(), z.unknown()); 734 741 735 742 export const zModelWithConst = z.object({ 736 743 String: z.optional(z.enum([ ··· 1005 1012 preconditions: z.optional(zIoK8sApimachineryPkgApisMetaV1Preconditions) 1006 1013 }); 1007 1014 1008 - export const zAdditionalPropertiesUnknownIssue = z.object({}); 1015 + export const zAdditionalPropertiesUnknownIssue = z.record(z.string(), z.union([ 1016 + z.string(), 1017 + z.number() 1018 + ])); 1009 1019 1010 - export const zAdditionalPropertiesUnknownIssue2 = z.object({}); 1020 + export const zAdditionalPropertiesUnknownIssue2 = z.record(z.string(), z.union([ 1021 + z.string(), 1022 + z.number() 1023 + ])); 1011 1024 1012 1025 export const zAdditionalPropertiesUnknownIssue3 = z.intersection(z.string(), z.object({ 1013 - entries: z.object({}) 1026 + entries: z.record(z.string(), zAdditionalPropertiesUnknownIssue) 1014 1027 })); 1015 1028 1016 1029 export const zAdditionalPropertiesIntegerIssue = z.object({ ··· 1024 1037 z.null() 1025 1038 ])), 1026 1039 hasError: z.optional(z.boolean().readonly()), 1027 - data: z.optional(z.object({})) 1040 + data: z.optional(z.record(z.string(), z.never())) 1028 1041 }); 1029 1042 1030 1043 export const zGenericSchemaDuplicateIssue1SystemString = z.object({ ··· 1185 1198 /** 1186 1199 * This is a string dictionary 1187 1200 */ 1188 - export const zDictionaryWithStringWritable = z.object({}); 1201 + export const zDictionaryWithStringWritable = z.record(z.string(), z.string()); 1189 1202 1190 1203 /** 1191 1204 * This is a string dictionary 1192 1205 */ 1193 - export const zDictionaryWithDictionaryWritable = z.record(z.string(), z.object({})); 1206 + export const zDictionaryWithDictionaryWritable = z.record(z.string(), z.record(z.string(), z.string())); 1194 1207 1195 1208 /** 1196 1209 * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) ··· 1223 1236 /** 1224 1237 * This is a free-form object without additionalProperties. 1225 1238 */ 1226 - export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.object({}); 1239 + export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.record(z.string(), z.unknown()); 1227 1240 1228 1241 /** 1229 1242 * This is a free-form object with additionalProperties: true. 1230 1243 */ 1231 - export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.object({}); 1244 + export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.record(z.string(), z.unknown()); 1232 1245 1233 1246 /** 1234 1247 * This is a free-form object with additionalProperties: {}. 1235 1248 */ 1236 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.object({}); 1249 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.record(z.string(), z.unknown()); 1237 1250 1238 1251 /** 1239 1252 * Some % character ··· 1334 1347 */ 1335 1348 export const zDeleteFooData2Writable = z.string(); 1336 1349 1337 - export const zAdditionalPropertiesUnknownIssueWritable = z.object({}); 1350 + export const zAdditionalPropertiesUnknownIssueWritable = z.record(z.string(), z.union([ 1351 + z.string(), 1352 + z.number() 1353 + ])); 1338 1354 1339 - export const zAdditionalPropertiesUnknownIssue2Writable = z.object({}); 1355 + export const zAdditionalPropertiesUnknownIssue2Writable = z.record(z.string(), z.union([ 1356 + z.string(), 1357 + z.number() 1358 + ])); 1340 1359 1341 1360 export const zOneOfAllOfIssueWritable = z.union([ 1342 1361 z.intersection(z.union([ ··· 1492 1511 1493 1512 export const zCallWithParametersData = z.object({ 1494 1513 body: z.union([ 1495 - z.object({}), 1514 + z.record(z.string(), z.unknown()), 1496 1515 z.null() 1497 1516 ]), 1498 1517 path: z.object({ ··· 1800 1819 z.null() 1801 1820 ]).default(true), 1802 1821 parameterObject: z.union([ 1803 - z.object({}), 1822 + z.record(z.string(), z.unknown()), 1804 1823 z.null() 1805 1824 ]).default(null), 1806 1825 parameterArray: z.union([ ··· 1808 1827 z.null() 1809 1828 ]), 1810 1829 parameterDictionary: z.union([ 1811 - z.object({}), 1830 + z.record(z.string(), z.unknown()), 1812 1831 z.null() 1813 1832 ]), 1814 1833 parameterEnum: z.enum([ ··· 1823 1842 z.number(), 1824 1843 z.string(), 1825 1844 z.boolean(), 1826 - z.object({}) 1845 + z.record(z.string(), z.unknown()) 1827 1846 ]); 1828 1847 1829 1848 export const zUploadFileData = z.object({
+47 -28
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/default/zod.gen.ts
··· 203 203 /** 204 204 * This is a string dictionary 205 205 */ 206 - export const zDictionaryWithString = z.object({}); 206 + export const zDictionaryWithString = z.record(z.string(), z.string()); 207 207 208 208 export const zDictionaryWithPropertiesAndAdditionalProperties = z.object({ 209 209 foo: z.optional(z.number()), ··· 213 213 /** 214 214 * This is a string reference 215 215 */ 216 - export const zDictionaryWithReference = z.object({}); 216 + export const zDictionaryWithReference = z.record(z.string(), zModelWithString); 217 217 218 218 /** 219 219 * This is a complex dictionary 220 220 */ 221 - export const zDictionaryWithArray = z.object({}); 221 + export const zDictionaryWithArray = z.record(z.string(), z.array(zModelWithString)); 222 222 223 223 /** 224 224 * This is a string dictionary 225 225 */ 226 - export const zDictionaryWithDictionary = z.record(z.string(), z.object({})); 226 + export const zDictionaryWithDictionary = z.record(z.string(), z.record(z.string(), z.string())); 227 227 228 228 /** 229 229 * This is a complex dictionary ··· 328 328 * This is a model with nested enums 329 329 */ 330 330 export const zModelWithNestedEnums = z.object({ 331 - dictionaryWithEnum: z.optional(z.object({})), 332 - dictionaryWithEnumFromDescription: z.optional(z.object({})), 331 + dictionaryWithEnum: z.optional(z.record(z.string(), z.enum([ 332 + 'Success', 333 + 'Warning', 334 + 'Error' 335 + ]))), 336 + dictionaryWithEnumFromDescription: z.optional(z.record(z.string(), z.int())), 333 337 arrayWithEnum: z.optional(z.array(z.enum([ 334 338 'Success', 335 339 'Warning', ··· 399 403 * This is a model with one property containing a dictionary 400 404 */ 401 405 export const zModelWithDictionary = z.object({ 402 - prop: z.optional(z.object({})) 406 + prop: z.optional(z.record(z.string(), z.string())) 403 407 }); 404 408 405 409 /** ··· 556 560 export const zCompositionWithOneOfAndSimpleDictionary = z.object({ 557 561 propA: z.optional(z.union([ 558 562 z.boolean(), 559 - z.object({}) 563 + z.record(z.string(), z.number()) 560 564 ])) 561 565 }); 562 566 ··· 566 570 export const zCompositionWithOneOfAndSimpleArrayDictionary = z.object({ 567 571 propA: z.optional(z.union([ 568 572 z.boolean(), 569 - z.object({}) 573 + z.record(z.string(), z.array(z.boolean())) 570 574 ])) 571 575 }); 572 576 ··· 576 580 export const zCompositionWithOneOfAndComplexArrayDictionary = z.object({ 577 581 propA: z.optional(z.union([ 578 582 z.boolean(), 579 - z.object({}) 583 + z.record(z.string(), z.array(z.union([ 584 + z.number(), 585 + z.string() 586 + ]))) 580 587 ])) 581 588 }); 582 589 ··· 721 728 /** 722 729 * This is a free-form object without additionalProperties. 723 730 */ 724 - export const zFreeFormObjectWithoutAdditionalProperties = z.object({}); 731 + export const zFreeFormObjectWithoutAdditionalProperties = z.record(z.string(), z.unknown()); 725 732 726 733 /** 727 734 * This is a free-form object with additionalProperties: true. 728 735 */ 729 - export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.object({}); 736 + export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.record(z.string(), z.unknown()); 730 737 731 738 /** 732 739 * This is a free-form object with additionalProperties: {}. 733 740 */ 734 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.object({}); 741 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.record(z.string(), z.unknown()); 735 742 736 743 export const zModelWithConst = z.object({ 737 744 String: z.optional(z.literal('String')), ··· 1005 1012 preconditions: z.optional(zIoK8sApimachineryPkgApisMetaV1Preconditions) 1006 1013 }); 1007 1014 1008 - export const zAdditionalPropertiesUnknownIssue = z.object({}); 1015 + export const zAdditionalPropertiesUnknownIssue = z.record(z.string(), z.union([ 1016 + z.string(), 1017 + z.number() 1018 + ])); 1009 1019 1010 - export const zAdditionalPropertiesUnknownIssue2 = z.object({}); 1020 + export const zAdditionalPropertiesUnknownIssue2 = z.record(z.string(), z.union([ 1021 + z.string(), 1022 + z.number() 1023 + ])); 1011 1024 1012 1025 export const zAdditionalPropertiesUnknownIssue3 = z.intersection(z.string(), z.object({ 1013 - entries: z.object({}) 1026 + entries: z.record(z.string(), zAdditionalPropertiesUnknownIssue) 1014 1027 })); 1015 1028 1016 1029 export const zAdditionalPropertiesIntegerIssue = z.object({ ··· 1024 1037 z.null() 1025 1038 ])), 1026 1039 hasError: z.optional(z.readonly(z.boolean())), 1027 - data: z.optional(z.object({})) 1040 + data: z.optional(z.record(z.string(), z.never())) 1028 1041 }); 1029 1042 1030 1043 export const zGenericSchemaDuplicateIssue1SystemString = z.object({ ··· 1185 1198 /** 1186 1199 * This is a string dictionary 1187 1200 */ 1188 - export const zDictionaryWithStringWritable = z.object({}); 1201 + export const zDictionaryWithStringWritable = z.record(z.string(), z.string()); 1189 1202 1190 1203 /** 1191 1204 * This is a string dictionary 1192 1205 */ 1193 - export const zDictionaryWithDictionaryWritable = z.record(z.string(), z.object({})); 1206 + export const zDictionaryWithDictionaryWritable = z.record(z.string(), z.record(z.string(), z.string())); 1194 1207 1195 1208 /** 1196 1209 * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) ··· 1221 1234 /** 1222 1235 * This is a free-form object without additionalProperties. 1223 1236 */ 1224 - export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.object({}); 1237 + export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.record(z.string(), z.unknown()); 1225 1238 1226 1239 /** 1227 1240 * This is a free-form object with additionalProperties: true. 1228 1241 */ 1229 - export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.object({}); 1242 + export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.record(z.string(), z.unknown()); 1230 1243 1231 1244 /** 1232 1245 * This is a free-form object with additionalProperties: {}. 1233 1246 */ 1234 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.object({}); 1247 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.record(z.string(), z.unknown()); 1235 1248 1236 1249 /** 1237 1250 * Some % character ··· 1332 1345 */ 1333 1346 export const zDeleteFooData2Writable = z.string(); 1334 1347 1335 - export const zAdditionalPropertiesUnknownIssueWritable = z.object({}); 1348 + export const zAdditionalPropertiesUnknownIssueWritable = z.record(z.string(), z.union([ 1349 + z.string(), 1350 + z.number() 1351 + ])); 1336 1352 1337 - export const zAdditionalPropertiesUnknownIssue2Writable = z.object({}); 1353 + export const zAdditionalPropertiesUnknownIssue2Writable = z.record(z.string(), z.union([ 1354 + z.string(), 1355 + z.number() 1356 + ])); 1338 1357 1339 1358 export const zOneOfAllOfIssueWritable = z.union([ 1340 1359 z.intersection(z.union([ ··· 1499 1518 1500 1519 export const zCallWithParametersData = z.object({ 1501 1520 body: z.union([ 1502 - z.object({}), 1521 + z.record(z.string(), z.unknown()), 1503 1522 z.null() 1504 1523 ]), 1505 1524 path: z.object({ ··· 1807 1826 z.null() 1808 1827 ]), true), 1809 1828 parameterObject: z._default(z.union([ 1810 - z.object({}), 1829 + z.record(z.string(), z.unknown()), 1811 1830 z.null() 1812 1831 ]), null), 1813 1832 parameterArray: z.union([ ··· 1815 1834 z.null() 1816 1835 ]), 1817 1836 parameterDictionary: z.union([ 1818 - z.object({}), 1837 + z.record(z.string(), z.unknown()), 1819 1838 z.null() 1820 1839 ]), 1821 1840 parameterEnum: z.union([ ··· 1831 1850 z.number(), 1832 1851 z.string(), 1833 1852 z.boolean(), 1834 - z.object({}) 1853 + z.record(z.string(), z.unknown()) 1835 1854 ]); 1836 1855 1837 1856 export const zUploadFileData = z.object({
+1 -1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/schema-const/zod.gen.ts
··· 14 14 z.literal('foo'), 15 15 z.literal(true) 16 16 ])), 17 - corge: z.optional(z.object({})), 17 + corge: z.optional(z.record(z.string(), z.unknown())), 18 18 garply: z.optional(z.coerce.bigint()), 19 19 numberInt8: z.optional(z.literal(100)), 20 20 numberInt16: z.optional(z.literal(1000)),
+47 -28
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/default/zod.gen.ts
··· 203 203 /** 204 204 * This is a string dictionary 205 205 */ 206 - export const zDictionaryWithString = z.object({}); 206 + export const zDictionaryWithString = z.record(z.string()); 207 207 208 208 export const zDictionaryWithPropertiesAndAdditionalProperties = z.object({ 209 209 foo: z.number().optional(), ··· 213 213 /** 214 214 * This is a string reference 215 215 */ 216 - export const zDictionaryWithReference = z.object({}); 216 + export const zDictionaryWithReference = z.record(zModelWithString); 217 217 218 218 /** 219 219 * This is a complex dictionary 220 220 */ 221 - export const zDictionaryWithArray = z.object({}); 221 + export const zDictionaryWithArray = z.record(z.array(zModelWithString)); 222 222 223 223 /** 224 224 * This is a string dictionary 225 225 */ 226 - export const zDictionaryWithDictionary = z.record(z.object({})); 226 + export const zDictionaryWithDictionary = z.record(z.record(z.string())); 227 227 228 228 /** 229 229 * This is a complex dictionary ··· 328 328 * This is a model with nested enums 329 329 */ 330 330 export const zModelWithNestedEnums = z.object({ 331 - dictionaryWithEnum: z.object({}).optional(), 332 - dictionaryWithEnumFromDescription: z.object({}).optional(), 331 + dictionaryWithEnum: z.record(z.enum([ 332 + 'Success', 333 + 'Warning', 334 + 'Error' 335 + ])).optional(), 336 + dictionaryWithEnumFromDescription: z.record(z.number().int()).optional(), 333 337 arrayWithEnum: z.array(z.enum([ 334 338 'Success', 335 339 'Warning', ··· 399 403 * This is a model with one property containing a dictionary 400 404 */ 401 405 export const zModelWithDictionary = z.object({ 402 - prop: z.object({}).optional() 406 + prop: z.record(z.string()).optional() 403 407 }); 404 408 405 409 /** ··· 554 558 export const zCompositionWithOneOfAndSimpleDictionary = z.object({ 555 559 propA: z.union([ 556 560 z.boolean(), 557 - z.object({}) 561 + z.record(z.number()) 558 562 ]).optional() 559 563 }); 560 564 ··· 564 568 export const zCompositionWithOneOfAndSimpleArrayDictionary = z.object({ 565 569 propA: z.union([ 566 570 z.boolean(), 567 - z.object({}) 571 + z.record(z.array(z.boolean())) 568 572 ]).optional() 569 573 }); 570 574 ··· 574 578 export const zCompositionWithOneOfAndComplexArrayDictionary = z.object({ 575 579 propA: z.union([ 576 580 z.boolean(), 577 - z.object({}) 581 + z.record(z.array(z.union([ 582 + z.number(), 583 + z.string() 584 + ]))) 578 585 ]).optional() 579 586 }); 580 587 ··· 719 726 /** 720 727 * This is a free-form object without additionalProperties. 721 728 */ 722 - export const zFreeFormObjectWithoutAdditionalProperties = z.object({}); 729 + export const zFreeFormObjectWithoutAdditionalProperties = z.record(z.unknown()); 723 730 724 731 /** 725 732 * This is a free-form object with additionalProperties: true. 726 733 */ 727 - export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.object({}); 734 + export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.record(z.unknown()); 728 735 729 736 /** 730 737 * This is a free-form object with additionalProperties: {}. 731 738 */ 732 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.object({}); 739 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.record(z.unknown()); 733 740 734 741 export const zModelWithConst = z.object({ 735 742 String: z.literal('String').optional(), ··· 1003 1010 preconditions: zIoK8sApimachineryPkgApisMetaV1Preconditions.optional() 1004 1011 }); 1005 1012 1006 - export const zAdditionalPropertiesUnknownIssue = z.object({}); 1013 + export const zAdditionalPropertiesUnknownIssue = z.record(z.union([ 1014 + z.string(), 1015 + z.number() 1016 + ])); 1007 1017 1008 - export const zAdditionalPropertiesUnknownIssue2 = z.object({}); 1018 + export const zAdditionalPropertiesUnknownIssue2 = z.record(z.union([ 1019 + z.string(), 1020 + z.number() 1021 + ])); 1009 1022 1010 1023 export const zAdditionalPropertiesUnknownIssue3 = z.intersection(z.string(), z.object({ 1011 - entries: z.object({}) 1024 + entries: z.record(zAdditionalPropertiesUnknownIssue) 1012 1025 })); 1013 1026 1014 1027 export const zAdditionalPropertiesIntegerIssue = z.object({ ··· 1022 1035 z.null() 1023 1036 ]).optional(), 1024 1037 hasError: z.boolean().readonly().optional(), 1025 - data: z.object({}).optional() 1038 + data: z.record(z.never()).optional() 1026 1039 }); 1027 1040 1028 1041 export const zGenericSchemaDuplicateIssue1SystemString = z.object({ ··· 1183 1196 /** 1184 1197 * This is a string dictionary 1185 1198 */ 1186 - export const zDictionaryWithStringWritable = z.object({}); 1199 + export const zDictionaryWithStringWritable = z.record(z.string()); 1187 1200 1188 1201 /** 1189 1202 * This is a string dictionary 1190 1203 */ 1191 - export const zDictionaryWithDictionaryWritable = z.record(z.object({})); 1204 + export const zDictionaryWithDictionaryWritable = z.record(z.record(z.string())); 1192 1205 1193 1206 /** 1194 1207 * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) ··· 1219 1232 /** 1220 1233 * This is a free-form object without additionalProperties. 1221 1234 */ 1222 - export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.object({}); 1235 + export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.record(z.unknown()); 1223 1236 1224 1237 /** 1225 1238 * This is a free-form object with additionalProperties: true. 1226 1239 */ 1227 - export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.object({}); 1240 + export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.record(z.unknown()); 1228 1241 1229 1242 /** 1230 1243 * This is a free-form object with additionalProperties: {}. 1231 1244 */ 1232 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.object({}); 1245 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.record(z.unknown()); 1233 1246 1234 1247 /** 1235 1248 * Some % character ··· 1330 1343 */ 1331 1344 export const zDeleteFooData2Writable = z.string(); 1332 1345 1333 - export const zAdditionalPropertiesUnknownIssueWritable = z.object({}); 1346 + export const zAdditionalPropertiesUnknownIssueWritable = z.record(z.union([ 1347 + z.string(), 1348 + z.number() 1349 + ])); 1334 1350 1335 - export const zAdditionalPropertiesUnknownIssue2Writable = z.object({}); 1351 + export const zAdditionalPropertiesUnknownIssue2Writable = z.record(z.union([ 1352 + z.string(), 1353 + z.number() 1354 + ])); 1336 1355 1337 1356 export const zOneOfAllOfIssueWritable = z.union([ 1338 1357 z.intersection(z.union([ ··· 1497 1516 1498 1517 export const zCallWithParametersData = z.object({ 1499 1518 body: z.union([ 1500 - z.object({}), 1519 + z.record(z.unknown()), 1501 1520 z.null() 1502 1521 ]), 1503 1522 path: z.object({ ··· 1805 1824 z.null() 1806 1825 ]).default(true), 1807 1826 parameterObject: z.union([ 1808 - z.object({}), 1827 + z.record(z.unknown()), 1809 1828 z.null() 1810 1829 ]).default(null), 1811 1830 parameterArray: z.union([ ··· 1813 1832 z.null() 1814 1833 ]), 1815 1834 parameterDictionary: z.union([ 1816 - z.object({}), 1835 + z.record(z.unknown()), 1817 1836 z.null() 1818 1837 ]), 1819 1838 parameterEnum: z.union([ ··· 1829 1848 z.number(), 1830 1849 z.string(), 1831 1850 z.boolean(), 1832 - z.object({}) 1851 + z.record(z.unknown()) 1833 1852 ]); 1834 1853 1835 1854 export const zUploadFileData = z.object({
+1 -1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/schema-const/zod.gen.ts
··· 14 14 z.literal('foo'), 15 15 z.literal(true) 16 16 ]).optional(), 17 - corge: z.object({}).optional(), 17 + corge: z.record(z.unknown()).optional(), 18 18 garply: z.coerce.bigint().optional(), 19 19 numberInt8: z.literal(100).optional(), 20 20 numberInt16: z.literal(1000).optional(),
+47 -28
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/default/zod.gen.ts
··· 203 203 /** 204 204 * This is a string dictionary 205 205 */ 206 - export const zDictionaryWithString = z.object({}); 206 + export const zDictionaryWithString = z.record(z.string(), z.string()); 207 207 208 208 export const zDictionaryWithPropertiesAndAdditionalProperties = z.object({ 209 209 foo: z.optional(z.number()), ··· 213 213 /** 214 214 * This is a string reference 215 215 */ 216 - export const zDictionaryWithReference = z.object({}); 216 + export const zDictionaryWithReference = z.record(z.string(), zModelWithString); 217 217 218 218 /** 219 219 * This is a complex dictionary 220 220 */ 221 - export const zDictionaryWithArray = z.object({}); 221 + export const zDictionaryWithArray = z.record(z.string(), z.array(zModelWithString)); 222 222 223 223 /** 224 224 * This is a string dictionary 225 225 */ 226 - export const zDictionaryWithDictionary = z.record(z.string(), z.object({})); 226 + export const zDictionaryWithDictionary = z.record(z.string(), z.record(z.string(), z.string())); 227 227 228 228 /** 229 229 * This is a complex dictionary ··· 328 328 * This is a model with nested enums 329 329 */ 330 330 export const zModelWithNestedEnums = z.object({ 331 - dictionaryWithEnum: z.optional(z.object({})), 332 - dictionaryWithEnumFromDescription: z.optional(z.object({})), 331 + dictionaryWithEnum: z.optional(z.record(z.string(), z.enum([ 332 + 'Success', 333 + 'Warning', 334 + 'Error' 335 + ]))), 336 + dictionaryWithEnumFromDescription: z.optional(z.record(z.string(), z.int())), 333 337 arrayWithEnum: z.optional(z.array(z.enum([ 334 338 'Success', 335 339 'Warning', ··· 399 403 * This is a model with one property containing a dictionary 400 404 */ 401 405 export const zModelWithDictionary = z.object({ 402 - prop: z.optional(z.object({})) 406 + prop: z.optional(z.record(z.string(), z.string())) 403 407 }); 404 408 405 409 /** ··· 556 560 export const zCompositionWithOneOfAndSimpleDictionary = z.object({ 557 561 propA: z.optional(z.union([ 558 562 z.boolean(), 559 - z.object({}) 563 + z.record(z.string(), z.number()) 560 564 ])) 561 565 }); 562 566 ··· 566 570 export const zCompositionWithOneOfAndSimpleArrayDictionary = z.object({ 567 571 propA: z.optional(z.union([ 568 572 z.boolean(), 569 - z.object({}) 573 + z.record(z.string(), z.array(z.boolean())) 570 574 ])) 571 575 }); 572 576 ··· 576 580 export const zCompositionWithOneOfAndComplexArrayDictionary = z.object({ 577 581 propA: z.optional(z.union([ 578 582 z.boolean(), 579 - z.object({}) 583 + z.record(z.string(), z.array(z.union([ 584 + z.number(), 585 + z.string() 586 + ]))) 580 587 ])) 581 588 }); 582 589 ··· 721 728 /** 722 729 * This is a free-form object without additionalProperties. 723 730 */ 724 - export const zFreeFormObjectWithoutAdditionalProperties = z.object({}); 731 + export const zFreeFormObjectWithoutAdditionalProperties = z.record(z.string(), z.unknown()); 725 732 726 733 /** 727 734 * This is a free-form object with additionalProperties: true. 728 735 */ 729 - export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.object({}); 736 + export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.record(z.string(), z.unknown()); 730 737 731 738 /** 732 739 * This is a free-form object with additionalProperties: {}. 733 740 */ 734 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.object({}); 741 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.record(z.string(), z.unknown()); 735 742 736 743 export const zModelWithConst = z.object({ 737 744 String: z.optional(z.literal('String')), ··· 1005 1012 preconditions: z.optional(zIoK8sApimachineryPkgApisMetaV1Preconditions) 1006 1013 }); 1007 1014 1008 - export const zAdditionalPropertiesUnknownIssue = z.object({}); 1015 + export const zAdditionalPropertiesUnknownIssue = z.record(z.string(), z.union([ 1016 + z.string(), 1017 + z.number() 1018 + ])); 1009 1019 1010 - export const zAdditionalPropertiesUnknownIssue2 = z.object({}); 1020 + export const zAdditionalPropertiesUnknownIssue2 = z.record(z.string(), z.union([ 1021 + z.string(), 1022 + z.number() 1023 + ])); 1011 1024 1012 1025 export const zAdditionalPropertiesUnknownIssue3 = z.intersection(z.string(), z.object({ 1013 - entries: z.object({}) 1026 + entries: z.record(z.string(), zAdditionalPropertiesUnknownIssue) 1014 1027 })); 1015 1028 1016 1029 export const zAdditionalPropertiesIntegerIssue = z.object({ ··· 1024 1037 z.null() 1025 1038 ])), 1026 1039 hasError: z.optional(z.boolean().readonly()), 1027 - data: z.optional(z.object({})) 1040 + data: z.optional(z.record(z.string(), z.never())) 1028 1041 }); 1029 1042 1030 1043 export const zGenericSchemaDuplicateIssue1SystemString = z.object({ ··· 1185 1198 /** 1186 1199 * This is a string dictionary 1187 1200 */ 1188 - export const zDictionaryWithStringWritable = z.object({}); 1201 + export const zDictionaryWithStringWritable = z.record(z.string(), z.string()); 1189 1202 1190 1203 /** 1191 1204 * This is a string dictionary 1192 1205 */ 1193 - export const zDictionaryWithDictionaryWritable = z.record(z.string(), z.object({})); 1206 + export const zDictionaryWithDictionaryWritable = z.record(z.string(), z.record(z.string(), z.string())); 1194 1207 1195 1208 /** 1196 1209 * `Comment` or `VoiceComment`. The JSON object for adding voice comments to tickets is different. See [Adding voice comments to tickets](/documentation/ticketing/managing-tickets/adding-voice-comments-to-tickets) ··· 1221 1234 /** 1222 1235 * This is a free-form object without additionalProperties. 1223 1236 */ 1224 - export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.object({}); 1237 + export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.record(z.string(), z.unknown()); 1225 1238 1226 1239 /** 1227 1240 * This is a free-form object with additionalProperties: true. 1228 1241 */ 1229 - export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.object({}); 1242 + export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.record(z.string(), z.unknown()); 1230 1243 1231 1244 /** 1232 1245 * This is a free-form object with additionalProperties: {}. 1233 1246 */ 1234 - export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.object({}); 1247 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.record(z.string(), z.unknown()); 1235 1248 1236 1249 /** 1237 1250 * Some % character ··· 1332 1345 */ 1333 1346 export const zDeleteFooData2Writable = z.string(); 1334 1347 1335 - export const zAdditionalPropertiesUnknownIssueWritable = z.object({}); 1348 + export const zAdditionalPropertiesUnknownIssueWritable = z.record(z.string(), z.union([ 1349 + z.string(), 1350 + z.number() 1351 + ])); 1336 1352 1337 - export const zAdditionalPropertiesUnknownIssue2Writable = z.object({}); 1353 + export const zAdditionalPropertiesUnknownIssue2Writable = z.record(z.string(), z.union([ 1354 + z.string(), 1355 + z.number() 1356 + ])); 1338 1357 1339 1358 export const zOneOfAllOfIssueWritable = z.union([ 1340 1359 z.intersection(z.union([ ··· 1499 1518 1500 1519 export const zCallWithParametersData = z.object({ 1501 1520 body: z.union([ 1502 - z.object({}), 1521 + z.record(z.string(), z.unknown()), 1503 1522 z.null() 1504 1523 ]), 1505 1524 path: z.object({ ··· 1807 1826 z.null() 1808 1827 ]).default(true), 1809 1828 parameterObject: z.union([ 1810 - z.object({}), 1829 + z.record(z.string(), z.unknown()), 1811 1830 z.null() 1812 1831 ]).default(null), 1813 1832 parameterArray: z.union([ ··· 1815 1834 z.null() 1816 1835 ]), 1817 1836 parameterDictionary: z.union([ 1818 - z.object({}), 1837 + z.record(z.string(), z.unknown()), 1819 1838 z.null() 1820 1839 ]), 1821 1840 parameterEnum: z.union([ ··· 1831 1850 z.number(), 1832 1851 z.string(), 1833 1852 z.boolean(), 1834 - z.object({}) 1853 + z.record(z.string(), z.unknown()) 1835 1854 ]); 1836 1855 1837 1856 export const zUploadFileData = z.object({
+1 -1
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/schema-const/zod.gen.ts
··· 14 14 z.literal('foo'), 15 15 z.literal(true) 16 16 ])), 17 - corge: z.optional(z.object({})), 17 + corge: z.optional(z.record(z.string(), z.unknown())), 18 18 garply: z.optional(z.coerce.bigint()), 19 19 numberInt8: z.optional(z.literal(100)), 20 20 numberInt16: z.optional(z.literal(1000)),
+22 -4
packages/openapi-ts/src/openApi/2.0.x/parser/schema.ts
··· 249 249 }; 250 250 } 251 251 } else if (typeof schema.additionalProperties === 'boolean') { 252 - irSchema.additionalProperties = { 253 - type: schema.additionalProperties ? 'unknown' : 'never', 254 - }; 252 + // Avoid [key: string]: never for empty objects with additionalProperties: false inside allOf 253 + // This would override inherited properties from other schemas in the composition 254 + const isEmptyObjectInAllOf = 255 + state.inAllOf && 256 + schema.additionalProperties === false && 257 + (!schema.properties || Object.keys(schema.properties).length === 0); 258 + 259 + if (!isEmptyObjectInAllOf) { 260 + irSchema.additionalProperties = { 261 + type: schema.additionalProperties ? 'unknown' : 'never', 262 + }; 263 + } 255 264 } else { 256 265 const irAdditionalPropertiesSchema = schemaToIrSchema({ 257 266 context, ··· 313 322 const compositionSchemas = schema.allOf; 314 323 315 324 for (const compositionSchema of compositionSchemas) { 325 + // Don't propagate inAllOf flag to $ref schemas to avoid issues with reusable components 326 + const isRef = '$ref' in compositionSchema; 327 + const schemaState = isRef 328 + ? state 329 + : { 330 + ...state, 331 + inAllOf: true, 332 + }; 333 + 316 334 const irCompositionSchema = schemaToIrSchema({ 317 335 context, 318 336 schema: compositionSchema, 319 - state, 337 + state: schemaState, 320 338 }); 321 339 322 340 irSchema.accessScopes = mergeSchemaAccessScopes(
+22 -4
packages/openapi-ts/src/openApi/3.0.x/parser/schema.ts
··· 259 259 }; 260 260 } 261 261 } else if (typeof schema.additionalProperties === 'boolean') { 262 - irSchema.additionalProperties = { 263 - type: schema.additionalProperties ? 'unknown' : 'never', 264 - }; 262 + // Avoid [key: string]: never for empty objects with additionalProperties: false inside allOf 263 + // This would override inherited properties from other schemas in the composition 264 + const isEmptyObjectInAllOf = 265 + state.inAllOf && 266 + schema.additionalProperties === false && 267 + (!schema.properties || Object.keys(schema.properties).length === 0); 268 + 269 + if (!isEmptyObjectInAllOf) { 270 + irSchema.additionalProperties = { 271 + type: schema.additionalProperties ? 'unknown' : 'never', 272 + }; 273 + } 265 274 } else { 266 275 const irAdditionalPropertiesSchema = schemaToIrSchema({ 267 276 context, ··· 323 332 const compositionSchemas = schema.allOf; 324 333 325 334 for (const compositionSchema of compositionSchemas) { 335 + // Don't propagate inAllOf flag to $ref schemas to avoid issues with reusable components 336 + const isRef = '$ref' in compositionSchema; 337 + const schemaState = isRef 338 + ? state 339 + : { 340 + ...state, 341 + inAllOf: true, 342 + }; 343 + 326 344 const irCompositionSchema = schemaToIrSchema({ 327 345 context, 328 346 schema: compositionSchema, 329 - state, 347 + state: schemaState, 330 348 }); 331 349 332 350 irSchema.accessScopes = mergeSchemaAccessScopes(
+22 -4
packages/openapi-ts/src/openApi/3.1.x/parser/schema.ts
··· 290 290 }; 291 291 } 292 292 } else if (typeof schema.additionalProperties === 'boolean') { 293 - irSchema.additionalProperties = { 294 - type: schema.additionalProperties ? 'unknown' : 'never', 295 - }; 293 + // Avoid [key: string]: never for empty objects with additionalProperties: false inside allOf 294 + // This would override inherited properties from other schemas in the composition 295 + const isEmptyObjectInAllOf = 296 + state.inAllOf && 297 + schema.additionalProperties === false && 298 + (!schema.properties || Object.keys(schema.properties).length === 0); 299 + 300 + if (!isEmptyObjectInAllOf) { 301 + irSchema.additionalProperties = { 302 + type: schema.additionalProperties ? 'unknown' : 'never', 303 + }; 304 + } 296 305 } else { 297 306 const irAdditionalPropertiesSchema = schemaToIrSchema({ 298 307 context, ··· 361 370 const compositionSchemas = schema.allOf; 362 371 363 372 for (const compositionSchema of compositionSchemas) { 373 + // Don't propagate inAllOf flag to $ref schemas to avoid issues with reusable components 374 + const isRef = '$ref' in compositionSchema; 375 + const schemaState = isRef 376 + ? state 377 + : { 378 + ...state, 379 + inAllOf: true, 380 + }; 381 + 364 382 const irCompositionSchema = schemaToIrSchema({ 365 383 context, 366 384 schema: compositionSchema, 367 - state, 385 + state: schemaState, 368 386 }); 369 387 370 388 if (schema.required) {
+7
packages/openapi-ts/src/openApi/shared/types/schema.d.ts
··· 6 6 $ref?: string; 7 7 circularReferenceTracker: Set<string>; 8 8 /** 9 + * True if current schema is part of an allOf composition. This is used to 10 + * avoid emitting [key: string]: never for empty objects with 11 + * additionalProperties: false inside allOf, which would override inherited 12 + * properties from other schemas in the composition. 13 + */ 14 + inAllOf?: boolean; 15 + /** 9 16 * True if current schema is an object property. This is used to mark schemas 10 17 * as "both" access scopes, i.e. they can be used in both payloads and 11 18 * responses. Without this field, we'd be overusing the "both" value which
+1 -2
packages/openapi-ts/src/plugins/zod/mini/plugin.ts
··· 469 469 470 470 if ( 471 471 schema.additionalProperties && 472 - schema.additionalProperties.type === 'object' && 473 - !Object.keys(properties).length 472 + (!schema.properties || !Object.keys(schema.properties).length) 474 473 ) { 475 474 const zodSchema = schemaToZodSchema({ 476 475 plugin,
+4 -3
packages/openapi-ts/src/plugins/zod/plugin.ts
··· 6 6 export const handler: ZodPlugin['Handler'] = (args) => { 7 7 const { plugin } = args; 8 8 switch (plugin.config.compatibilityVersion) { 9 + case 3: 10 + return handlerV3(args); 9 11 case 4: 10 - default: 11 12 return handlerV4(args); 12 13 case 'mini': 13 14 return handlerMini(args); 14 - case 3: 15 - return handlerV3(args); 15 + default: 16 + return handlerV4(args); 16 17 } 17 18 };
+1 -2
packages/openapi-ts/src/plugins/zod/v3/plugin.ts
··· 391 391 392 392 if ( 393 393 schema.additionalProperties && 394 - schema.additionalProperties.type === 'object' && 395 - !Object.keys(properties).length 394 + (!schema.properties || !Object.keys(schema.properties).length) 396 395 ) { 397 396 const zodSchema = schemaToZodSchema({ 398 397 plugin,
+18 -2
packages/openapi-ts/src/plugins/zod/v4/plugin.ts
··· 431 431 432 432 if ( 433 433 schema.additionalProperties && 434 - schema.additionalProperties.type === 'object' && 435 - !Object.keys(properties).length 434 + (!schema.properties || !Object.keys(schema.properties).length) 436 435 ) { 437 436 const zodSchema = schemaToZodSchema({ 438 437 plugin, ··· 458 457 if (zodSchema.hasCircularReference) { 459 458 result.hasCircularReference = true; 460 459 } 460 + 461 + // Return with typeName for circular references 462 + if (result.hasCircularReference) { 463 + return { 464 + ...result, 465 + typeName: 'ZodType', 466 + } as ZodSchema; 467 + } 468 + 461 469 return result as Omit<ZodSchema, 'typeName'>; 462 470 } 463 471 ··· 468 476 }), 469 477 parameters: [ts.factory.createObjectLiteralExpression(properties, true)], 470 478 }); 479 + 480 + // Return with typeName for circular references (AnyZodObject doesn't exist in Zod v4, use ZodType) 481 + if (result.hasCircularReference) { 482 + return { 483 + ...result, 484 + typeName: 'ZodType', 485 + } as ZodSchema; 486 + } 471 487 472 488 return result as Omit<ZodSchema, 'typeName'>; 473 489 };