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.

test: update snapshots

Lubos cce2789d 517b2619

+11832 -630
+2 -2
package.json
··· 27 27 "lint:fix": "prettier --check --write . && eslint . --fix", 28 28 "lint": "prettier --check . && eslint .", 29 29 "openapi-ts": "turbo run $1 --filter=\"@hey-api/openapi-ts\"", 30 - "openapi-ts-tests": "turbo run $1 --filter=\"./packages/openapi-ts-tests/*\"", 31 - "openapi-ts-tests-sample": "turbo run $1 --filter=\"./packages/openapi-ts-tests/zod/v3\"", 30 + "openapi-ts-tests": "turbo run $1 --filter=\"./packages/openapi-ts-tests/**/*\"", 31 + "openapi-ts-tests-sample": "turbo run $1 --filter=\"./packages/openapi-ts-tests/zod/v4\"", 32 32 "prepare": "husky", 33 33 "test:coverage": "turbo run test:coverage", 34 34 "test:e2e": "turbo run test:e2e",
+3 -3
packages/openapi-ts-tests/main/test/3.0.x.test.ts
··· 69 69 config: createConfig({ 70 70 input: 'array-items-one-of-length-1.yaml', 71 71 output: 'array-items-one-of-length-1', 72 - plugins: ['@hey-api/typescript', 'valibot', 'zod'], 72 + plugins: ['@hey-api/typescript', 'valibot'], 73 73 }), 74 74 description: 75 75 'generates correct array when items are oneOf array with single item', ··· 454 454 config: createConfig({ 455 455 input: 'enum-null.json', 456 456 output: 'enum-null', 457 - plugins: ['@hey-api/typescript', 'valibot', 'zod'], 457 + plugins: ['@hey-api/typescript', 'valibot'], 458 458 }), 459 459 description: 'handles null enums', 460 460 }, ··· 623 623 config: createConfig({ 624 624 input: 'validators.json', 625 625 output: 'validators', 626 - plugins: ['valibot', 'zod'], 626 + plugins: ['valibot'], 627 627 }), 628 628 description: 'generates validator schemas', 629 629 },
+9 -42
packages/openapi-ts-tests/main/test/3.1.x.test.ts
··· 69 69 config: createConfig({ 70 70 input: 'array-items-one-of-length-1.yaml', 71 71 output: 'array-items-one-of-length-1', 72 - plugins: ['@hey-api/typescript', 'valibot', 'zod'], 72 + plugins: ['@hey-api/typescript', 'valibot'], 73 73 }), 74 74 description: 75 75 'generates correct array when items are oneOf array with single item', ··· 468 468 config: createConfig({ 469 469 input: 'enum-null.json', 470 470 output: 'enum-null', 471 - plugins: ['@hey-api/typescript', 'valibot', 'zod'], 471 + plugins: ['@hey-api/typescript', 'valibot'], 472 472 }), 473 473 description: 'handles null enums', 474 474 }, ··· 624 624 config: createConfig({ 625 625 input: 'schema-const.yaml', 626 626 output: 'schema-const', 627 - plugins: ['@hey-api/typescript', 'valibot', 'zod'], 627 + plugins: ['@hey-api/typescript', 'valibot'], 628 628 }), 629 629 description: 'handles various constants', 630 630 }, ··· 741 741 config: createConfig({ 742 742 input: 'validators.yaml', 743 743 output: 'validators', 744 - plugins: ['valibot', 'zod'], 744 + plugins: ['valibot'], 745 745 }), 746 746 description: 'generates validator schemas', 747 - }, 748 - { 749 - config: createConfig({ 750 - input: 'validators.yaml', 751 - output: 'validators-dates', 752 - plugins: [ 753 - // Valibot doesn't allow configuring offset 754 - // { 755 - // name: 'valibot', 756 - // }, 757 - { 758 - dates: { 759 - offset: true, 760 - }, 761 - name: 'zod', 762 - }, 763 - ], 764 - }), 765 - description: 'generates validator schemas with any offset', 766 747 }, 767 748 { 768 749 config: createConfig({ ··· 773 754 metadata: true, 774 755 name: 'valibot', 775 756 }, 776 - { 777 - metadata: true, 778 - name: 'zod', 779 - }, 780 757 ], 781 758 }), 782 759 description: 'generates validator schemas with metadata', ··· 785 762 config: createConfig({ 786 763 input: 'validators.yaml', 787 764 output: 'validators-types', 788 - plugins: [ 789 - { 790 - name: 'valibot', 791 - }, 792 - { 793 - name: 'zod', 794 - types: { 795 - infer: true, 796 - }, 797 - }, 798 - ], 765 + plugins: ['valibot'], 799 766 }), 800 767 description: 'generates validator schemas with types', 801 768 }, ··· 803 770 config: createConfig({ 804 771 input: 'validators-bigint-min-max.json', 805 772 output: 'validators-bigint-min-max', 806 - plugins: ['valibot', 'zod'], 773 + plugins: ['valibot'], 807 774 }), 808 775 description: 'validator schemas with BigInt and min/max constraints', 809 776 }, ··· 811 778 config: createConfig({ 812 779 input: 'validators-circular-ref.json', 813 780 output: 'validators-circular-ref', 814 - plugins: ['valibot', 'zod'], 781 + plugins: ['valibot'], 815 782 }), 816 783 description: 'validator schemas with circular reference', 817 784 }, ··· 819 786 config: createConfig({ 820 787 input: 'validators-circular-ref-2.yaml', 821 788 output: 'validators-circular-ref-2', 822 - plugins: ['valibot', 'zod'], 789 + plugins: ['valibot'], 823 790 }), 824 791 description: 'validator schemas with circular reference 2', 825 792 }, ··· 827 794 config: createConfig({ 828 795 input: 'validators-union-merge.json', 829 796 output: 'validators-union-merge', 830 - plugins: ['valibot', 'zod'], 797 + plugins: ['valibot'], 831 798 }), 832 799 description: "validator schemas with merged unions (can't use .merge())", 833 800 },
+5 -3
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/zod/default/zod.gen.ts packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v4/default/zod.gen.ts
··· 293 293 * This is a model with one property containing a circular reference 294 294 */ 295 295 export const zModelWithCircularReference = z.object({ 296 - prop: z.optional(z.lazy(() => { 297 - return zModelWithCircularReference; 298 - })) 296 + get prop(): z.ZodOptional { 297 + return z.optional(z.lazy((): any => { 298 + return zModelWithCircularReference; 299 + })); 300 + } 299 301 }); 300 302 301 303 /**
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/array-items-one-of-length-1/zod.gen.ts packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/array-items-one-of-length-1/zod.gen.ts
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/enum-null/zod.gen.ts packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/enum-null/zod.gen.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - import { z } from 'zod'; 3 + import { z } from 'zod/v3'; 4 4 5 5 export const zFoo = z.enum([ 6 6 'foo',
+5 -3
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/zod/default/zod.gen.ts packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/default/zod.gen.ts
··· 411 411 * This is a model with one property containing a circular reference 412 412 */ 413 413 export const zModelWithCircularReference = z.object({ 414 - prop: z.optional(z.lazy(() => { 415 - return zModelWithCircularReference; 416 - })) 414 + get prop(): z.ZodOptional { 415 + return z.optional(z.lazy((): any => { 416 + return zModelWithCircularReference; 417 + })); 418 + } 417 419 }); 418 420 419 421 /**
+8 -6
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/validators/zod.gen.ts packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/validators/zod.gen.ts
··· 3 3 import { z } from 'zod'; 4 4 5 5 export const zBar = z.object({ 6 - foo: z.optional(z.lazy(() => { 7 - return zFoo; 8 - })) 6 + get foo(): z.ZodOptional { 7 + return z.optional(zFoo); 8 + } 9 9 }); 10 10 11 11 export const zFoo = z.union([ 12 12 z.object({ 13 13 foo: z.optional(z.string().regex(/^\d{3}-\d{2}-\d{4}$/)), 14 14 bar: z.optional(zBar), 15 - baz: z.optional(z.array(z.lazy(() => { 16 - return zFoo; 17 - }))), 15 + get baz(): z.ZodOptional { 16 + return z.optional(z.array(z.lazy((): any => { 17 + return zFoo; 18 + }))); 19 + }, 18 20 qux: z.optional(z.int().gt(0)).default(0) 19 21 }), 20 22 z.null()
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/array-items-one-of-length-1/zod.gen.ts packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/array-items-one-of-length-1/zod.gen.ts
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/enum-null/zod.gen.ts packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/enum-null/zod.gen.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 - import { z } from 'zod'; 3 + import { z } from 'zod/v3'; 4 4 5 5 export const zFoo = z.enum([ 6 6 'foo',
+5 -3
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/zod/default/zod.gen.ts packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/default/zod.gen.ts
··· 414 414 * This is a model with one property containing a circular reference 415 415 */ 416 416 export const zModelWithCircularReference = z.object({ 417 - prop: z.optional(z.lazy(() => { 418 - return zModelWithCircularReference; 419 - })) 417 + get prop(): z.ZodOptional { 418 + return z.optional(z.lazy((): any => { 419 + return zModelWithCircularReference; 420 + })); 421 + } 420 422 }); 421 423 422 424 /**
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/schema-const/zod.gen.ts packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/schema-const/zod.gen.ts
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-bigint-min-max/zod.gen.ts packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-bigint-min-max/zod.gen.ts
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-circular-ref-2/zod.gen.ts packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-circular-ref-2/zod.gen.ts
··· 4 4 5 5 export const zBar = z.object({ 6 6 bar: z.union([ 7 - z.array(z.lazy(() => { 7 + z.array(z.lazy((): any => { 8 8 return zBar; 9 9 })), 10 10 z.null()
+6 -4
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-circular-ref/zod.gen.ts packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-circular-ref/zod.gen.ts
··· 3 3 import { z } from 'zod'; 4 4 5 5 export const zBar = z.object({ 6 - bar: z.optional(z.array(z.lazy(() => { 7 - return zBar; 8 - }))) 6 + get bar(): z.ZodOptional { 7 + return z.optional(z.array(z.lazy((): any => { 8 + return zBar; 9 + }))); 10 + } 9 11 }); 10 12 11 13 export const zFoo = z.object({ ··· 15 17 /** 16 18 * description caused circular reference error 17 19 */ 18 - export const zQux = z.lazy(() => { 20 + export const zQux = z.lazy((): any => { 19 21 return zQux; 20 22 }); 21 23
+8 -6
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-dates/zod.gen.ts packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-dates/zod.gen.ts
··· 6 6 * This is Bar schema. 7 7 */ 8 8 export const zBar = z.object({ 9 - foo: z.optional(z.lazy(() => { 10 - return zFoo; 11 - })) 9 + get foo(): z.ZodOptional { 10 + return z.optional(zFoo); 11 + } 12 12 }); 13 13 14 14 /** ··· 18 18 z.object({ 19 19 foo: z.optional(z.string().regex(/^\d{3}-\d{2}-\d{4}$/)), 20 20 bar: z.optional(zBar), 21 - baz: z.optional(z.array(z.lazy(() => { 22 - return zFoo; 23 - }))), 21 + get baz(): z.ZodOptional { 22 + return z.optional(z.array(z.lazy((): any => { 23 + return zFoo; 24 + }))); 25 + }, 24 26 qux: z.optional(z.int().gt(0)).default(0) 25 27 }), 26 28 z.null()
+10 -8
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-metadata/zod.gen.ts packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-metadata/zod.gen.ts
··· 6 6 * This is Bar schema. 7 7 */ 8 8 export const zBar = z.object({ 9 - foo: z.optional(z.lazy(() => { 10 - return zFoo; 11 - })) 9 + get foo(): z.ZodOptional { 10 + return z.optional(zFoo); 11 + } 12 12 }).register(z.globalRegistry, { 13 13 description: 'This is Bar schema.' 14 14 }); ··· 22 22 description: 'This is foo property.' 23 23 })), 24 24 bar: z.optional(zBar), 25 - baz: z.optional(z.array(z.lazy(() => { 26 - return zFoo; 27 - })).register(z.globalRegistry, { 28 - description: 'This is baz property.' 29 - })), 25 + get baz(): z.ZodOptional { 26 + return z.optional(z.array(z.lazy((): any => { 27 + return zFoo; 28 + })).register(z.globalRegistry, { 29 + description: 'This is baz property.' 30 + })); 31 + }, 30 32 qux: z.optional(z.int().gt(0).register(z.globalRegistry, { 31 33 description: 'This is qux property.' 32 34 })).default(0)
+8 -6
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-types/zod.gen.ts packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-types/zod.gen.ts
··· 6 6 * This is Bar schema. 7 7 */ 8 8 export const zBar = z.object({ 9 - foo: z.optional(z.lazy(() => { 10 - return zFoo; 11 - })) 9 + get foo(): z.ZodOptional { 10 + return z.optional(zFoo); 11 + } 12 12 }); 13 13 14 14 export type BarZodType = z.infer<typeof zBar>; ··· 20 20 z.object({ 21 21 foo: z.optional(z.string().regex(/^\d{3}-\d{2}-\d{4}$/)), 22 22 bar: z.optional(zBar), 23 - baz: z.optional(z.array(z.lazy(() => { 24 - return zFoo; 25 - }))), 23 + get baz(): z.ZodOptional { 24 + return z.optional(z.array(z.lazy((): any => { 25 + return zFoo; 26 + }))); 27 + }, 26 28 qux: z.optional(z.int().gt(0)).default(0) 27 29 }), 28 30 z.null()
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators-union-merge/zod.gen.ts packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators-union-merge/zod.gen.ts
+8 -6
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/validators/zod.gen.ts packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/validators/zod.gen.ts
··· 6 6 * This is Bar schema. 7 7 */ 8 8 export const zBar = z.object({ 9 - foo: z.optional(z.lazy(() => { 10 - return zFoo; 11 - })) 9 + get foo(): z.ZodOptional { 10 + return z.optional(zFoo); 11 + } 12 12 }); 13 13 14 14 /** ··· 18 18 z.object({ 19 19 foo: z.optional(z.string().regex(/^\d{3}-\d{2}-\d{4}$/)), 20 20 bar: z.optional(zBar), 21 - baz: z.optional(z.array(z.lazy(() => { 22 - return zFoo; 23 - }))), 21 + get baz(): z.ZodOptional { 22 + return z.optional(z.array(z.lazy((): any => { 23 + return zFoo; 24 + }))); 25 + }, 24 26 qux: z.optional(z.int().gt(0)).default(0) 25 27 }), 26 28 z.null()
+12 -16
packages/openapi-ts-tests/main/test/openapi-ts.config.ts
··· 40 40 path: path.resolve( 41 41 getSpecsPath(), 42 42 '3.1.x', 43 - // 'case.yaml', 44 - // 'enum-inline.yaml', 45 - 'full.yaml', 46 - // 'object-property-names.yaml', 47 - // 'transformers-all-of.yaml', 48 - // 'validators.yaml', 43 + // 'full.yaml', 44 + 'validators-circular-ref.json', 49 45 ), 50 46 // path: 'http://localhost:4000/', 51 47 // path: 'https://get.heyapi.dev/', ··· 225 221 { 226 222 // case: 'snake_case', 227 223 // comments: false, 228 - compatibilityVersion: 'mini', 229 - dates: { 230 - offset: true, 231 - }, 224 + compatibilityVersion: 4, 225 + // dates: { 226 + // offset: true, 227 + // }, 232 228 definitions: { 233 - name: 'z{{name}}Definition', 229 + // name: 'z{{name}}Definition', 234 230 // types: { 235 231 // infer: 'D{{name}}ZodType', 236 232 // }, ··· 252 248 // infer: 'F{{name}}ResponseZodType', 253 249 // }, 254 250 // }, 255 - types: { 256 - infer: { 257 - case: 'snake_case', 258 - }, 259 - }, 251 + // types: { 252 + // infer: { 253 + // case: 'snake_case', 254 + // }, 255 + // }, 260 256 }, 261 257 { 262 258 exportFromIndex: true,
-7
packages/openapi-ts-tests/main/test/plugins.test.ts
··· 420 420 }, 421 421 { 422 422 config: createConfig({ 423 - output: 'default', 424 - plugins: ['zod'], 425 - }), 426 - description: 'generate Zod schemas with Zod plugin', 427 - }, 428 - { 429 - config: createConfig({ 430 423 input: 'type-format.yaml', 431 424 output: 'type-format-valibot', 432 425 plugins: [
+1
packages/openapi-ts-tests/tsconfig.base.json
··· 4 4 "esModuleInterop": true, 5 5 "module": "ESNext", 6 6 "moduleResolution": "Bundler", 7 + "noImplicitAny": true, 7 8 "noImplicitOverride": true, 8 9 "noImplicitReturns": true, 9 10 "noUncheckedIndexedAccess": true,
+5 -3
packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/mini/default/zod.gen.ts
··· 293 293 * This is a model with one property containing a circular reference 294 294 */ 295 295 export const zModelWithCircularReference = z.object({ 296 - prop: z.optional(z.lazy(() => { 297 - return zModelWithCircularReference; 298 - })) 296 + get prop(): z.ZodMiniOptional { 297 + return z.optional(z.lazy((): any => { 298 + return zModelWithCircularReference; 299 + })); 300 + } 299 301 }); 300 302 301 303 /**
+5 -3
packages/openapi-ts-tests/zod/v3/__snapshots__/2.0.x/v4/default/zod.gen.ts
··· 293 293 * This is a model with one property containing a circular reference 294 294 */ 295 295 export const zModelWithCircularReference = z.object({ 296 - prop: z.optional(z.lazy(() => { 297 - return zModelWithCircularReference; 298 - })) 296 + get prop(): z.ZodOptional { 297 + return z.optional(z.lazy((): any => { 298 + return zModelWithCircularReference; 299 + })); 300 + } 299 301 }); 300 302 301 303 /**
+1 -1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/array-items-one-of-length-1/zod.gen.ts
··· 5 5 export const zBar = z.string(); 6 6 7 7 export const zFoo = z.object({ 8 - foo: z.optional(z.array(zBar).min(1).max(2147483647)) 8 + foo: z.optional(z.array(zBar).check(z.minLength(1), z.maxLength(2147483647))) 9 9 });
+5 -3
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/default/zod.gen.ts
··· 411 411 * This is a model with one property containing a circular reference 412 412 */ 413 413 export const zModelWithCircularReference = z.object({ 414 - prop: z.optional(z.lazy(() => { 415 - return zModelWithCircularReference; 416 - })) 414 + get prop(): z.ZodMiniOptional { 415 + return z.optional(z.lazy((): any => { 416 + return zModelWithCircularReference; 417 + })); 418 + } 417 419 }); 418 420 419 421 /**
+2 -2
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/enum-null/zod.gen.ts
··· 2 2 3 3 import * as z from 'zod/v4-mini'; 4 4 5 - export const zFoo = z.enum([ 5 + export const zFoo = z.nullable(z.enum([ 6 6 'foo', 7 7 'bar' 8 - ]).nullable(); 8 + ])); 9 9 10 10 export const zBar = z.enum([ 11 11 'foo',
+8 -6
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/mini/validators/zod.gen.ts
··· 3 3 import * as z from 'zod/v4-mini'; 4 4 5 5 export const zBar = z.object({ 6 - foo: z.optional(z.lazy(() => { 7 - return zFoo; 8 - })) 6 + get foo(): z.ZodMiniOptional { 7 + return z.optional(zFoo); 8 + } 9 9 }); 10 10 11 11 export const zFoo = z._default(z.union([ 12 12 z.object({ 13 13 foo: z.optional(z.string().check(z.regex(/^\d{3}-\d{2}-\d{4}$/))), 14 14 bar: z.optional(zBar), 15 - baz: z.optional(z.array(z.lazy(() => { 16 - return zFoo; 17 - }))), 15 + get baz(): z.ZodMiniOptional { 16 + return z.optional(z.array(z.lazy((): any => { 17 + return zFoo; 18 + }))); 19 + }, 18 20 qux: z._default(z.optional(z.int().check(z.gt(0))), 0) 19 21 }), 20 22 z.null()
+5 -3
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/default/zod.gen.ts
··· 411 411 * This is a model with one property containing a circular reference 412 412 */ 413 413 export const zModelWithCircularReference = z.object({ 414 - prop: z.optional(z.lazy(() => { 415 - return zModelWithCircularReference; 416 - })) 414 + get prop(): z.ZodOptional { 415 + return z.optional(z.lazy((): any => { 416 + return zModelWithCircularReference; 417 + })); 418 + } 417 419 }); 418 420 419 421 /**
+2 -2
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/enum-null/zod.gen.ts
··· 2 2 3 3 import { z } from 'zod/v4'; 4 4 5 - export const zFoo = z.enum([ 5 + export const zFoo = z.nullable(z.enum([ 6 6 'foo', 7 7 'bar' 8 - ]).nullable(); 8 + ])); 9 9 10 10 export const zBar = z.enum([ 11 11 'foo',
+8 -6
packages/openapi-ts-tests/zod/v3/__snapshots__/3.0.x/v4/validators/zod.gen.ts
··· 3 3 import { z } from 'zod/v4'; 4 4 5 5 export const zBar = z.object({ 6 - foo: z.optional(z.lazy(() => { 7 - return zFoo; 8 - })) 6 + get foo(): z.ZodOptional { 7 + return z.optional(zFoo); 8 + } 9 9 }); 10 10 11 11 export const zFoo = z.union([ 12 12 z.object({ 13 13 foo: z.optional(z.string().regex(/^\d{3}-\d{2}-\d{4}$/)), 14 14 bar: z.optional(zBar), 15 - baz: z.optional(z.array(z.lazy(() => { 16 - return zFoo; 17 - }))), 15 + get baz(): z.ZodOptional { 16 + return z.optional(z.array(z.lazy((): any => { 17 + return zFoo; 18 + }))); 19 + }, 18 20 qux: z.optional(z.int().gt(0)).default(0) 19 21 }), 20 22 z.null()
+1 -1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/array-items-one-of-length-1/zod.gen.ts
··· 5 5 export const zBar = z.string(); 6 6 7 7 export const zFoo = z.object({ 8 - foo: z.optional(z.array(zBar).min(1).max(2147483647)) 8 + foo: z.optional(z.array(zBar).check(z.minLength(1), z.maxLength(2147483647))) 9 9 });
+5 -3
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/default/zod.gen.ts
··· 414 414 * This is a model with one property containing a circular reference 415 415 */ 416 416 export const zModelWithCircularReference = z.object({ 417 - prop: z.optional(z.lazy(() => { 418 - return zModelWithCircularReference; 419 - })) 417 + get prop(): z.ZodMiniOptional { 418 + return z.optional(z.lazy((): any => { 419 + return zModelWithCircularReference; 420 + })); 421 + } 420 422 }); 421 423 422 424 /**
+2 -2
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/enum-null/zod.gen.ts
··· 2 2 3 3 import * as z from 'zod/v4-mini'; 4 4 5 - export const zFoo = z.enum([ 5 + export const zFoo = z.nullable(z.enum([ 6 6 'foo', 7 7 'bar' 8 - ]).nullable(); 8 + ])); 9 9 10 10 export const zBar = z.enum([ 11 11 'foo',
+1 -1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-circular-ref-2/zod.gen.ts
··· 4 4 5 5 export const zBar = z.object({ 6 6 bar: z.union([ 7 - z.array(z.lazy(() => { 7 + z.array(z.lazy((): any => { 8 8 return zBar; 9 9 })), 10 10 z.null()
+6 -4
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-circular-ref/zod.gen.ts
··· 3 3 import * as z from 'zod/v4-mini'; 4 4 5 5 export const zBar = z.object({ 6 - bar: z.optional(z.array(z.lazy(() => { 7 - return zBar; 8 - }))) 6 + get bar(): z.ZodMiniOptional { 7 + return z.optional(z.array(z.lazy((): any => { 8 + return zBar; 9 + }))); 10 + } 9 11 }); 10 12 11 13 export const zFoo = z.object({ ··· 15 17 /** 16 18 * description caused circular reference error 17 19 */ 18 - export const zQux = z.lazy(() => { 20 + export const zQux = z.lazy((): any => { 19 21 return zQux; 20 22 }); 21 23
+8 -6
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-dates/zod.gen.ts
··· 6 6 * This is Bar schema. 7 7 */ 8 8 export const zBar = z.object({ 9 - foo: z.optional(z.lazy(() => { 10 - return zFoo; 11 - })) 9 + get foo(): z.ZodMiniOptional { 10 + return z.optional(zFoo); 11 + } 12 12 }); 13 13 14 14 /** ··· 18 18 z.object({ 19 19 foo: z.optional(z.string().check(z.regex(/^\d{3}-\d{2}-\d{4}$/))), 20 20 bar: z.optional(zBar), 21 - baz: z.optional(z.array(z.lazy(() => { 22 - return zFoo; 23 - }))), 21 + get baz(): z.ZodMiniOptional { 22 + return z.optional(z.array(z.lazy((): any => { 23 + return zFoo; 24 + }))); 25 + }, 24 26 qux: z._default(z.optional(z.int().check(z.gt(0))), 0) 25 27 }), 26 28 z.null()
+10 -8
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-metadata/zod.gen.ts
··· 6 6 * This is Bar schema. 7 7 */ 8 8 export const zBar = z.object({ 9 - foo: z.optional(z.lazy(() => { 10 - return zFoo; 11 - })) 9 + get foo(): z.ZodMiniOptional { 10 + return z.optional(zFoo); 11 + } 12 12 }).register(z.globalRegistry, { 13 13 description: 'This is Bar schema.' 14 14 }); ··· 22 22 description: 'This is foo property.' 23 23 })), 24 24 bar: z.optional(zBar), 25 - baz: z.optional(z.array(z.lazy(() => { 26 - return zFoo; 27 - })).register(z.globalRegistry, { 28 - description: 'This is baz property.' 29 - })), 25 + get baz(): z.ZodMiniOptional { 26 + return z.optional(z.array(z.lazy((): any => { 27 + return zFoo; 28 + })).register(z.globalRegistry, { 29 + description: 'This is baz property.' 30 + })); 31 + }, 30 32 qux: z._default(z.optional(z.int().check(z.gt(0)).register(z.globalRegistry, { 31 33 description: 'This is qux property.' 32 34 })), 0)
+8 -6
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators-types/zod.gen.ts
··· 6 6 * This is Bar schema. 7 7 */ 8 8 export const zBar = z.object({ 9 - foo: z.optional(z.lazy(() => { 10 - return zFoo; 11 - })) 9 + get foo(): z.ZodMiniOptional { 10 + return z.optional(zFoo); 11 + } 12 12 }); 13 13 14 14 export type BarZodType = z.infer<typeof zBar>; ··· 20 20 z.object({ 21 21 foo: z.optional(z.string().check(z.regex(/^\d{3}-\d{2}-\d{4}$/))), 22 22 bar: z.optional(zBar), 23 - baz: z.optional(z.array(z.lazy(() => { 24 - return zFoo; 25 - }))), 23 + get baz(): z.ZodMiniOptional { 24 + return z.optional(z.array(z.lazy((): any => { 25 + return zFoo; 26 + }))); 27 + }, 26 28 qux: z._default(z.optional(z.int().check(z.gt(0))), 0) 27 29 }), 28 30 z.null()
+8 -6
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/mini/validators/zod.gen.ts
··· 6 6 * This is Bar schema. 7 7 */ 8 8 export const zBar = z.object({ 9 - foo: z.optional(z.lazy(() => { 10 - return zFoo; 11 - })) 9 + get foo(): z.ZodMiniOptional { 10 + return z.optional(zFoo); 11 + } 12 12 }); 13 13 14 14 /** ··· 18 18 z.object({ 19 19 foo: z.optional(z.string().check(z.regex(/^\d{3}-\d{2}-\d{4}$/))), 20 20 bar: z.optional(zBar), 21 - baz: z.optional(z.array(z.lazy(() => { 22 - return zFoo; 23 - }))), 21 + get baz(): z.ZodMiniOptional { 22 + return z.optional(z.array(z.lazy((): any => { 23 + return zFoo; 24 + }))); 25 + }, 24 26 qux: z._default(z.optional(z.int().check(z.gt(0))), 0) 25 27 }), 26 28 z.null()
+5 -3
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/default/zod.gen.ts
··· 414 414 * This is a model with one property containing a circular reference 415 415 */ 416 416 export const zModelWithCircularReference = z.object({ 417 - prop: z.optional(z.lazy(() => { 418 - return zModelWithCircularReference; 419 - })) 417 + get prop(): z.ZodOptional { 418 + return z.optional(z.lazy((): any => { 419 + return zModelWithCircularReference; 420 + })); 421 + } 420 422 }); 421 423 422 424 /**
+2 -2
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/enum-null/zod.gen.ts
··· 2 2 3 3 import { z } from 'zod/v4'; 4 4 5 - export const zFoo = z.enum([ 5 + export const zFoo = z.nullable(z.enum([ 6 6 'foo', 7 7 'bar' 8 - ]).nullable(); 8 + ])); 9 9 10 10 export const zBar = z.enum([ 11 11 'foo',
+1 -1
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-circular-ref-2/zod.gen.ts
··· 4 4 5 5 export const zBar = z.object({ 6 6 bar: z.union([ 7 - z.array(z.lazy(() => { 7 + z.array(z.lazy((): any => { 8 8 return zBar; 9 9 })), 10 10 z.null()
+6 -4
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-circular-ref/zod.gen.ts
··· 3 3 import { z } from 'zod/v4'; 4 4 5 5 export const zBar = z.object({ 6 - bar: z.optional(z.array(z.lazy(() => { 7 - return zBar; 8 - }))) 6 + get bar(): z.ZodOptional { 7 + return z.optional(z.array(z.lazy((): any => { 8 + return zBar; 9 + }))); 10 + } 9 11 }); 10 12 11 13 export const zFoo = z.object({ ··· 15 17 /** 16 18 * description caused circular reference error 17 19 */ 18 - export const zQux = z.lazy(() => { 20 + export const zQux = z.lazy((): any => { 19 21 return zQux; 20 22 }); 21 23
+8 -6
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-dates/zod.gen.ts
··· 6 6 * This is Bar schema. 7 7 */ 8 8 export const zBar = z.object({ 9 - foo: z.optional(z.lazy(() => { 10 - return zFoo; 11 - })) 9 + get foo(): z.ZodOptional { 10 + return z.optional(zFoo); 11 + } 12 12 }); 13 13 14 14 /** ··· 18 18 z.object({ 19 19 foo: z.optional(z.string().regex(/^\d{3}-\d{2}-\d{4}$/)), 20 20 bar: z.optional(zBar), 21 - baz: z.optional(z.array(z.lazy(() => { 22 - return zFoo; 23 - }))), 21 + get baz(): z.ZodOptional { 22 + return z.optional(z.array(z.lazy((): any => { 23 + return zFoo; 24 + }))); 25 + }, 24 26 qux: z.optional(z.int().gt(0)).default(0) 25 27 }), 26 28 z.null()
+10 -8
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-metadata/zod.gen.ts
··· 6 6 * This is Bar schema. 7 7 */ 8 8 export const zBar = z.object({ 9 - foo: z.optional(z.lazy(() => { 10 - return zFoo; 11 - })) 9 + get foo(): z.ZodOptional { 10 + return z.optional(zFoo); 11 + } 12 12 }).register(z.globalRegistry, { 13 13 description: 'This is Bar schema.' 14 14 }); ··· 22 22 description: 'This is foo property.' 23 23 })), 24 24 bar: z.optional(zBar), 25 - baz: z.optional(z.array(z.lazy(() => { 26 - return zFoo; 27 - })).register(z.globalRegistry, { 28 - description: 'This is baz property.' 29 - })), 25 + get baz(): z.ZodOptional { 26 + return z.optional(z.array(z.lazy((): any => { 27 + return zFoo; 28 + })).register(z.globalRegistry, { 29 + description: 'This is baz property.' 30 + })); 31 + }, 30 32 qux: z.optional(z.int().gt(0).register(z.globalRegistry, { 31 33 description: 'This is qux property.' 32 34 })).default(0)
+8 -6
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators-types/zod.gen.ts
··· 6 6 * This is Bar schema. 7 7 */ 8 8 export const zBar = z.object({ 9 - foo: z.optional(z.lazy(() => { 10 - return zFoo; 11 - })) 9 + get foo(): z.ZodOptional { 10 + return z.optional(zFoo); 11 + } 12 12 }); 13 13 14 14 export type BarZodType = z.infer<typeof zBar>; ··· 20 20 z.object({ 21 21 foo: z.optional(z.string().regex(/^\d{3}-\d{2}-\d{4}$/)), 22 22 bar: z.optional(zBar), 23 - baz: z.optional(z.array(z.lazy(() => { 24 - return zFoo; 25 - }))), 23 + get baz(): z.ZodOptional { 24 + return z.optional(z.array(z.lazy((): any => { 25 + return zFoo; 26 + }))); 27 + }, 26 28 qux: z.optional(z.int().gt(0)).default(0) 27 29 }), 28 30 z.null()
+8 -6
packages/openapi-ts-tests/zod/v3/__snapshots__/3.1.x/v4/validators/zod.gen.ts
··· 6 6 * This is Bar schema. 7 7 */ 8 8 export const zBar = z.object({ 9 - foo: z.optional(z.lazy(() => { 10 - return zFoo; 11 - })) 9 + get foo(): z.ZodOptional { 10 + return z.optional(zFoo); 11 + } 12 12 }); 13 13 14 14 /** ··· 18 18 z.object({ 19 19 foo: z.optional(z.string().regex(/^\d{3}-\d{2}-\d{4}$/)), 20 20 bar: z.optional(zBar), 21 - baz: z.optional(z.array(z.lazy(() => { 22 - return zFoo; 23 - }))), 21 + get baz(): z.ZodOptional { 22 + return z.optional(z.array(z.lazy((): any => { 23 + return zFoo; 24 + }))); 25 + }, 24 26 qux: z.optional(z.int().gt(0)).default(0) 25 27 }), 26 28 z.null()
-1
packages/openapi-ts-tests/zod/v3/package.json
··· 5 5 "type": "module", 6 6 "scripts": { 7 7 "test:coverage": "vitest run --coverage", 8 - "test:sample": "openapi-ts -i ../../specs/3.1.x/validators.yaml -o ./generated/sample", 9 8 "test:update": "vitest watch --update", 10 9 "test:watch": "vitest watch", 11 10 "test": "vitest run",
+19
packages/openapi-ts-tests/zod/v4/.gitignore
··· 1 + .DS_Store 2 + .idea 3 + .tsup 4 + .tmp 5 + junit.xml 6 + logs 7 + node_modules 8 + npm-debug.log* 9 + temp 10 + yarn-debug.log* 11 + yarn-error.log* 12 + 13 + *.iml 14 + dist 15 + coverage 16 + .env 17 + 18 + # test files 19 + .gen/
+743
packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/mini/default/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as z from 'zod/mini'; 4 + 5 + /** 6 + * Testing multiline comments in string: First line 7 + * Second line 8 + * 9 + * Fourth line 10 + */ 11 + export const zCommentWithBreaks = z.int(); 12 + 13 + /** 14 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 15 + */ 16 + export const zCommentWithBackticks = z.int(); 17 + 18 + /** 19 + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 20 + */ 21 + export const zCommentWithBackticksAndQuotes = z.int(); 22 + 23 + /** 24 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 25 + */ 26 + export const zCommentWithSlashes = z.int(); 27 + 28 + /** 29 + * Testing expression placeholders in string: ${expression} should work 30 + */ 31 + export const zCommentWithExpressionPlaceholders = z.int(); 32 + 33 + /** 34 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 35 + */ 36 + export const zCommentWithQuotes = z.int(); 37 + 38 + /** 39 + * Testing reserved characters in string: * inline * and ** inline ** should work 40 + */ 41 + export const zCommentWithReservedCharacters = z.int(); 42 + 43 + /** 44 + * This is a simple number 45 + */ 46 + export const zSimpleInteger = z.int(); 47 + 48 + /** 49 + * This is a simple boolean 50 + */ 51 + export const zSimpleBoolean = z.boolean(); 52 + 53 + /** 54 + * This is a simple string 55 + */ 56 + export const zSimpleString = z.string(); 57 + 58 + /** 59 + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 60 + */ 61 + export const zNonAsciiStringæøåÆøÅöôêÊ字符串 = z.string(); 62 + 63 + /** 64 + * This is a simple file 65 + */ 66 + export const zSimpleFile = z.string(); 67 + 68 + /** 69 + * This is a model with one string property 70 + */ 71 + export const zModelWithString = z.object({ 72 + prop: z.optional(z.string()) 73 + }); 74 + 75 + export const zSimpleReference = zModelWithString; 76 + 77 + /** 78 + * This is a simple string 79 + */ 80 + export const zSimpleStringWithPattern = z.string().check(z.maxLength(64), z.regex(/^[a-zA-Z0-9_]*$/)); 81 + 82 + /** 83 + * This is a simple enum with strings 84 + */ 85 + export const zEnumWithStrings = z.enum([ 86 + 'Success', 87 + 'Warning', 88 + 'Error', 89 + "'Single Quote'", 90 + '"Double Quotes"', 91 + 'Non-ascii: øæåôöØÆÅÔÖ字符串' 92 + ]); 93 + 94 + /** 95 + * This is a simple enum with numbers 96 + */ 97 + export const zEnumWithNumbers = z.unknown(); 98 + 99 + /** 100 + * Success=1,Warning=2,Error=3 101 + */ 102 + export const zEnumFromDescription = z.number(); 103 + 104 + /** 105 + * This is a simple enum with numbers 106 + */ 107 + export const zEnumWithExtensions = z.unknown(); 108 + 109 + /** 110 + * This is a simple array with numbers 111 + */ 112 + export const zArrayWithNumbers = z.array(z.int()); 113 + 114 + /** 115 + * This is a simple array with booleans 116 + */ 117 + export const zArrayWithBooleans = z.array(z.boolean()); 118 + 119 + /** 120 + * This is a simple array with strings 121 + */ 122 + export const zArrayWithStrings = z.array(z.string()); 123 + 124 + /** 125 + * This is a simple array with references 126 + */ 127 + export const zArrayWithReferences = z.array(zModelWithString); 128 + 129 + /** 130 + * This is a simple array containing an array 131 + */ 132 + export const zArrayWithArray = z.array(z.array(zModelWithString)); 133 + 134 + /** 135 + * This is a simple array with properties 136 + */ 137 + export const zArrayWithProperties = z.array(z.object({ 138 + foo: z.optional(z.string()), 139 + bar: z.optional(z.string()) 140 + })); 141 + 142 + /** 143 + * This is a string dictionary 144 + */ 145 + export const zDictionaryWithString = z.object({}); 146 + 147 + /** 148 + * This is a string reference 149 + */ 150 + export const zDictionaryWithReference = z.object({}); 151 + 152 + /** 153 + * This is a complex dictionary 154 + */ 155 + export const zDictionaryWithArray = z.object({}); 156 + 157 + /** 158 + * This is a string dictionary 159 + */ 160 + export const zDictionaryWithDictionary = z.record(z.string(), z.object({})); 161 + 162 + /** 163 + * This is a complex dictionary 164 + */ 165 + export const zDictionaryWithProperties = z.record(z.string(), z.object({ 166 + foo: z.optional(z.string()), 167 + bar: z.optional(z.string()) 168 + })); 169 + 170 + /** 171 + * This is a type-only model that defines Date as a string 172 + */ 173 + export const zDate = z.string(); 174 + 175 + /** 176 + * This is a model with one number property 177 + */ 178 + export const zModelWithInteger = z.object({ 179 + prop: z.optional(z.int()) 180 + }); 181 + 182 + /** 183 + * This is a model with one boolean property 184 + */ 185 + export const zModelWithBoolean = z.object({ 186 + prop: z.optional(z.boolean()) 187 + }); 188 + 189 + /** 190 + * This is a model with one string property 191 + */ 192 + export const zModelWithStringError = z.object({ 193 + prop: z.optional(z.string()) 194 + }); 195 + 196 + /** 197 + * This is a model with one string property 198 + */ 199 + export const zModelWithNullableString = z.object({ 200 + nullableProp: z.optional(z.union([ 201 + z.string(), 202 + z.null() 203 + ])), 204 + nullableRequiredProp: z.union([ 205 + z.string(), 206 + z.null() 207 + ]) 208 + }); 209 + 210 + /** 211 + * This is a model with one enum 212 + */ 213 + export const zModelWithEnum = z.object({ 214 + test: z.optional(z.enum([ 215 + 'Success', 216 + 'Warning', 217 + 'Error', 218 + 'ØÆÅ字符串' 219 + ])), 220 + statusCode: z.optional(z.enum([ 221 + '100', 222 + '200 FOO', 223 + '300 FOO_BAR', 224 + '400 foo-bar', 225 + '500 foo.bar', 226 + '600 foo&bar' 227 + ])), 228 + bool: z.optional(z.unknown()) 229 + }); 230 + 231 + /** 232 + * This is a model with one enum 233 + */ 234 + export const zModelWithEnumFromDescription = z.object({ 235 + test: z.optional(z.int()) 236 + }); 237 + 238 + /** 239 + * This is a model with nested enums 240 + */ 241 + export const zModelWithNestedEnums = z.object({ 242 + dictionaryWithEnum: z.optional(z.object({})), 243 + dictionaryWithEnumFromDescription: z.optional(z.object({})), 244 + arrayWithEnum: z.optional(z.array(z.enum([ 245 + 'Success', 246 + 'Warning', 247 + 'Error' 248 + ]))), 249 + arrayWithDescription: z.optional(z.array(z.int())) 250 + }); 251 + 252 + /** 253 + * This is a model with one nested property 254 + */ 255 + export const zModelWithProperties = z.object({ 256 + required: z.string(), 257 + requiredAndReadOnly: z.readonly(z.string()), 258 + string: z.optional(z.string()), 259 + number: z.optional(z.number()), 260 + boolean: z.optional(z.boolean()), 261 + reference: z.optional(zModelWithString), 262 + 'property with space': z.optional(z.string()), 263 + default: z.optional(z.string()), 264 + try: z.optional(z.string()), 265 + '@namespace.string': z.optional(z.readonly(z.string())), 266 + '@namespace.integer': z.optional(z.readonly(z.int())) 267 + }); 268 + 269 + /** 270 + * This is a model with one property containing a reference 271 + */ 272 + export const zModelWithReference = z.object({ 273 + prop: z.optional(zModelWithProperties) 274 + }); 275 + 276 + /** 277 + * This is a model with one property containing an array 278 + */ 279 + export const zModelWithArray = z.object({ 280 + prop: z.optional(z.array(zModelWithString)), 281 + propWithFile: z.optional(z.array(z.string())), 282 + propWithNumber: z.optional(z.array(z.number())) 283 + }); 284 + 285 + /** 286 + * This is a model with one property containing a dictionary 287 + */ 288 + export const zModelWithDictionary = z.object({ 289 + prop: z.optional(z.object({})) 290 + }); 291 + 292 + /** 293 + * This is a model with one property containing a circular reference 294 + */ 295 + export const zModelWithCircularReference = z.object({ 296 + get prop(): z.ZodMiniOptional { 297 + return z.optional(z.lazy((): any => { 298 + return zModelWithCircularReference; 299 + })); 300 + } 301 + }); 302 + 303 + /** 304 + * This is a model with one nested property 305 + */ 306 + export const zModelWithNestedProperties = z.object({ 307 + first: z.readonly(z.object({ 308 + second: z.readonly(z.object({ 309 + third: z.readonly(z.string()) 310 + })) 311 + })) 312 + }); 313 + 314 + /** 315 + * This is a model with duplicated properties 316 + */ 317 + export const zModelWithDuplicateProperties = z.object({ 318 + prop: z.optional(zModelWithString) 319 + }); 320 + 321 + /** 322 + * This is a model with ordered properties 323 + */ 324 + export const zModelWithOrderedProperties = z.object({ 325 + zebra: z.optional(z.string()), 326 + apple: z.optional(z.string()), 327 + hawaii: z.optional(z.string()) 328 + }); 329 + 330 + /** 331 + * This is a model with duplicated imports 332 + */ 333 + export const zModelWithDuplicateImports = z.object({ 334 + propA: z.optional(zModelWithString), 335 + propB: z.optional(zModelWithString), 336 + propC: z.optional(zModelWithString) 337 + }); 338 + 339 + /** 340 + * This is a model that extends another model 341 + */ 342 + export const zModelThatExtends = z.intersection(zModelWithString, z.object({ 343 + propExtendsA: z.optional(z.string()), 344 + propExtendsB: z.optional(zModelWithString) 345 + })); 346 + 347 + /** 348 + * This is a model that extends another model 349 + */ 350 + export const zModelThatExtendsExtends = z.intersection(z.intersection(zModelWithString, zModelThatExtends), z.object({ 351 + propExtendsC: z.optional(z.string()), 352 + propExtendsD: z.optional(zModelWithString) 353 + })); 354 + 355 + export const zDefault = z.object({ 356 + name: z.optional(z.string()) 357 + }); 358 + 359 + /** 360 + * This is a model that contains a some patterns 361 + */ 362 + export const zModelWithPattern = z.object({ 363 + key: z.string().check(z.maxLength(64), z.regex(/^[a-zA-Z0-9_]*$/)), 364 + name: z.string().check(z.maxLength(255)), 365 + enabled: z.optional(z.readonly(z.boolean())), 366 + modified: z.optional(z.readonly(z.iso.datetime())), 367 + id: z.optional(z.string().check(z.regex(/^\d{2}-\d{3}-\d{4}$/))), 368 + text: z.optional(z.string().check(z.regex(/^\w+$/))), 369 + patternWithSingleQuotes: z.optional(z.string().check(z.regex(/^[a-zA-Z0-9']*$/))), 370 + patternWithNewline: z.optional(z.string().check(z.regex(/aaa\nbbb/))), 371 + patternWithBacktick: z.optional(z.string().check(z.regex(/aaa`bbb/))) 372 + }); 373 + 374 + export const zParameterActivityParams = z.object({ 375 + description: z.optional(z.string()), 376 + graduate_id: z.optional(z.int()), 377 + organization_id: z.optional(z.int()), 378 + parent_activity: z.optional(z.int()), 379 + post_id: z.optional(z.int()) 380 + }); 381 + 382 + export const zResponsePostActivityResponse = z.object({ 383 + description: z.optional(z.string()), 384 + graduate_id: z.optional(z.int()), 385 + organization_id: z.optional(z.int()), 386 + parent_activity_id: z.optional(z.int()), 387 + post_id: z.optional(z.int()) 388 + }); 389 + 390 + export const zFailureFailure = z.object({ 391 + error: z.optional(z.string()), 392 + message: z.optional(z.string()), 393 + reference_code: z.optional(z.string()) 394 + }); 395 + 396 + export const zServiceWithEmptyTagData = z.object({ 397 + body: z.optional(z.never()), 398 + path: z.optional(z.never()), 399 + query: z.optional(z.never()) 400 + }); 401 + 402 + export const zPatchApiVbyApiVersionNoTagData = z.object({ 403 + body: z.optional(z.never()), 404 + path: z.optional(z.never()), 405 + query: z.optional(z.never()) 406 + }); 407 + 408 + export const zFooWowData = z.object({ 409 + body: z.optional(z.never()), 410 + path: z.optional(z.never()), 411 + query: z.optional(z.never()) 412 + }); 413 + 414 + export const zDeleteCallWithoutParametersAndResponseData = z.object({ 415 + body: z.optional(z.never()), 416 + path: z.optional(z.never()), 417 + query: z.optional(z.never()) 418 + }); 419 + 420 + export const zGetCallWithoutParametersAndResponseData = z.object({ 421 + body: z.optional(z.never()), 422 + path: z.optional(z.never()), 423 + query: z.optional(z.never()) 424 + }); 425 + 426 + export const zHeadCallWithoutParametersAndResponseData = z.object({ 427 + body: z.optional(z.never()), 428 + path: z.optional(z.never()), 429 + query: z.optional(z.never()) 430 + }); 431 + 432 + export const zOptionsCallWithoutParametersAndResponseData = z.object({ 433 + body: z.optional(z.never()), 434 + path: z.optional(z.never()), 435 + query: z.optional(z.never()) 436 + }); 437 + 438 + export const zPatchCallWithoutParametersAndResponseData = z.object({ 439 + body: z.optional(z.never()), 440 + path: z.optional(z.never()), 441 + query: z.optional(z.never()) 442 + }); 443 + 444 + export const zPostCallWithoutParametersAndResponseData = z.object({ 445 + body: z.optional(z.never()), 446 + path: z.optional(z.never()), 447 + query: z.optional(z.never()) 448 + }); 449 + 450 + export const zPutCallWithoutParametersAndResponseData = z.object({ 451 + body: z.optional(z.never()), 452 + path: z.optional(z.never()), 453 + query: z.optional(z.never()) 454 + }); 455 + 456 + export const zCallWithDescriptionsData = z.object({ 457 + body: z.optional(z.never()), 458 + path: z.optional(z.never()), 459 + query: z.optional(z.object({ 460 + parameterWithBreaks: z.optional(z.string()), 461 + parameterWithBackticks: z.optional(z.string()), 462 + parameterWithSlashes: z.optional(z.string()), 463 + parameterWithExpressionPlaceholders: z.optional(z.string()), 464 + parameterWithQuotes: z.optional(z.string()), 465 + parameterWithReservedCharacters: z.optional(z.string()) 466 + })) 467 + }); 468 + 469 + export const zCallWithParametersData = z.object({ 470 + body: z.optional(z.never()), 471 + path: z.object({ 472 + parameterPath: z.string(), 473 + 'api-version': z.string() 474 + }), 475 + query: z.object({ 476 + parameterQuery: z.string() 477 + }), 478 + headers: z.object({ 479 + parameterHeader: z.string() 480 + }) 481 + }); 482 + 483 + export const zCallWithWeirdParameterNamesData = z.object({ 484 + body: z.optional(z.never()), 485 + path: z.object({ 486 + 'parameter.path.1': z.optional(z.string()), 487 + 'parameter-path-2': z.optional(z.string()), 488 + 'PARAMETER-PATH-3': z.optional(z.string()), 489 + 'api-version': z.string() 490 + }), 491 + query: z.object({ 492 + default: z.optional(z.string()), 493 + 'parameter-query': z.string() 494 + }), 495 + headers: z.object({ 496 + 'parameter.header': z.string() 497 + }) 498 + }); 499 + 500 + export const zCallWithDefaultParametersData = z.object({ 501 + body: z.optional(z.never()), 502 + path: z.optional(z.never()), 503 + query: z.object({ 504 + parameterString: z._default(z.string(), 'Hello World!'), 505 + parameterNumber: z._default(z.number(), 123), 506 + parameterBoolean: z._default(z.boolean(), true), 507 + parameterEnum: z.enum([ 508 + 'Success', 509 + 'Warning', 510 + 'Error' 511 + ]), 512 + parameterModel: z._default(z.object({ 513 + prop: z.optional(z.string()) 514 + }), { 515 + prop: 'Hello World!' 516 + }) 517 + }) 518 + }); 519 + 520 + export const zCallWithDefaultOptionalParametersData = z.object({ 521 + body: z.optional(z.never()), 522 + path: z.optional(z.never()), 523 + query: z.optional(z.object({ 524 + parameterString: z._default(z.optional(z.string()), 'Hello World!'), 525 + parameterNumber: z._default(z.optional(z.number()), 123), 526 + parameterBoolean: z._default(z.optional(z.boolean()), true), 527 + parameterEnum: z.optional(z.enum([ 528 + 'Success', 529 + 'Warning', 530 + 'Error' 531 + ])) 532 + })) 533 + }); 534 + 535 + export const zCallToTestOrderOfParamsData = z.object({ 536 + body: z.optional(z.never()), 537 + path: z.optional(z.never()), 538 + query: z.object({ 539 + parameterOptionalStringWithDefault: z._default(z.optional(z.string()), 'Hello World!'), 540 + parameterOptionalStringWithEmptyDefault: z._default(z.optional(z.string()), ''), 541 + parameterOptionalStringWithNoDefault: z.optional(z.string()), 542 + parameterStringWithDefault: z._default(z.string(), 'Hello World!'), 543 + parameterStringWithEmptyDefault: z._default(z.string(), ''), 544 + parameterStringWithNoDefault: z.string(), 545 + parameterStringNullableWithNoDefault: z.optional(z.union([ 546 + z.string(), 547 + z.null() 548 + ])), 549 + parameterStringNullableWithDefault: z._default(z.optional(z.union([ 550 + z.string(), 551 + z.null() 552 + ])), null) 553 + }) 554 + }); 555 + 556 + export const zDuplicateNameData = z.object({ 557 + body: z.optional(z.never()), 558 + path: z.optional(z.never()), 559 + query: z.optional(z.never()) 560 + }); 561 + 562 + export const zDuplicateName2Data = z.object({ 563 + body: z.optional(z.never()), 564 + path: z.optional(z.never()), 565 + query: z.optional(z.never()) 566 + }); 567 + 568 + export const zDuplicateName3Data = z.object({ 569 + body: z.optional(z.never()), 570 + path: z.optional(z.never()), 571 + query: z.optional(z.never()) 572 + }); 573 + 574 + export const zDuplicateName4Data = z.object({ 575 + body: z.optional(z.never()), 576 + path: z.optional(z.never()), 577 + query: z.optional(z.never()) 578 + }); 579 + 580 + export const zCallWithNoContentResponseData = z.object({ 581 + body: z.optional(z.never()), 582 + path: z.optional(z.never()), 583 + query: z.optional(z.never()) 584 + }); 585 + 586 + export const zCallWithResponseAndNoContentResponseData = z.object({ 587 + body: z.optional(z.never()), 588 + path: z.optional(z.never()), 589 + query: z.optional(z.never()) 590 + }); 591 + 592 + export const zCallWithResponseAndNoContentResponseResponse = z.union([ 593 + z.number(), 594 + z.unknown() 595 + ]); 596 + 597 + export const zDummyAData = z.object({ 598 + body: z.optional(z.never()), 599 + path: z.optional(z.never()), 600 + query: z.optional(z.never()) 601 + }); 602 + 603 + export const zDummyBData = z.object({ 604 + body: z.optional(z.never()), 605 + path: z.optional(z.never()), 606 + query: z.optional(z.never()) 607 + }); 608 + 609 + export const zCallWithResponseData = z.object({ 610 + body: z.optional(z.never()), 611 + path: z.optional(z.never()), 612 + query: z.optional(z.never()) 613 + }); 614 + 615 + /** 616 + * Message for default response 617 + */ 618 + export const zCallWithResponseResponse = zModelWithString; 619 + 620 + export const zCallWithDuplicateResponsesData = z.object({ 621 + body: z.optional(z.never()), 622 + path: z.optional(z.never()), 623 + query: z.optional(z.never()) 624 + }); 625 + 626 + /** 627 + * Message for 201 response 628 + */ 629 + export const zCallWithDuplicateResponsesResponse = zModelWithString; 630 + 631 + export const zCallWithResponsesData = z.object({ 632 + body: z.optional(z.never()), 633 + path: z.optional(z.never()), 634 + query: z.optional(z.never()) 635 + }); 636 + 637 + export const zCallWithResponsesResponse = z.union([ 638 + z.object({ 639 + '@namespace.string': z.optional(z.readonly(z.string())), 640 + '@namespace.integer': z.optional(z.readonly(z.int())), 641 + value: z.optional(z.readonly(z.array(zModelWithString))) 642 + }), 643 + zModelThatExtends, 644 + zModelThatExtendsExtends 645 + ]); 646 + 647 + export const zCollectionFormatData = z.object({ 648 + body: z.optional(z.never()), 649 + path: z.optional(z.never()), 650 + query: z.object({ 651 + parameterArrayCSV: z.array(z.string()), 652 + parameterArraySSV: z.array(z.string()), 653 + parameterArrayTSV: z.array(z.string()), 654 + parameterArrayPipes: z.array(z.string()), 655 + parameterArrayMulti: z.array(z.string()) 656 + }) 657 + }); 658 + 659 + export const zTypesData = z.object({ 660 + body: z.optional(z.never()), 661 + path: z.optional(z.object({ 662 + id: z.optional(z.int()) 663 + })), 664 + query: z.object({ 665 + parameterNumber: z._default(z.number(), 123), 666 + parameterString: z._default(z.string(), 'default'), 667 + parameterBoolean: z._default(z.boolean(), true), 668 + parameterArray: z.array(z.string()), 669 + parameterDictionary: z.object({}), 670 + parameterEnum: z.enum([ 671 + 'Success', 672 + 'Warning', 673 + 'Error' 674 + ]) 675 + }) 676 + }); 677 + 678 + export const zTypesResponse = z.union([ 679 + z.number(), 680 + z.string(), 681 + z.boolean(), 682 + z.object({}) 683 + ]); 684 + 685 + export const zComplexTypesData = z.object({ 686 + body: z.optional(z.never()), 687 + path: z.optional(z.never()), 688 + query: z.object({ 689 + parameterObject: z.object({ 690 + first: z.optional(z.object({ 691 + second: z.optional(z.object({ 692 + third: z.optional(z.string()) 693 + })) 694 + })) 695 + }), 696 + parameterReference: z.object({ 697 + prop: z.optional(z.string()) 698 + }) 699 + }) 700 + }); 701 + 702 + /** 703 + * Successful response 704 + */ 705 + export const zComplexTypesResponse = z.array(zModelWithString); 706 + 707 + export const zCallWithResultFromHeaderData = z.object({ 708 + body: z.optional(z.never()), 709 + path: z.optional(z.never()), 710 + query: z.optional(z.never()) 711 + }); 712 + 713 + export const zTestErrorCodeData = z.object({ 714 + body: z.optional(z.never()), 715 + path: z.optional(z.never()), 716 + query: z.object({ 717 + status: z.string() 718 + }) 719 + }); 720 + 721 + export const zNonAsciiæøåÆøÅöôêÊ字符串Data = z.object({ 722 + body: z.optional(z.never()), 723 + path: z.optional(z.never()), 724 + query: z.object({ 725 + 'nonAsciiParamæøåÆØÅöôêÊ': z.int() 726 + }) 727 + }); 728 + 729 + /** 730 + * Successful response 731 + */ 732 + export const zNonAsciiæøåÆøÅöôêÊ字符串Response = zNonAsciiStringæøåÆøÅöôêÊ字符串; 733 + 734 + export const zPostApiVbyApiVersionBodyData = z.object({ 735 + body: zParameterActivityParams, 736 + path: z.optional(z.never()), 737 + query: z.optional(z.never()) 738 + }); 739 + 740 + /** 741 + * OK 742 + */ 743 + export const zPostApiVbyApiVersionBodyResponse = zResponsePostActivityResponse;
+24
packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/mini/type-format-zod/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as z from 'zod/mini'; 4 + 5 + export const zFoo = z.object({ 6 + bar: z.optional(z.int()), 7 + foo: z._default(z.coerce.bigint(), BigInt(0)), 8 + id: z.string() 9 + }); 10 + 11 + export const zBar = z.object({ 12 + foo: z.int() 13 + }); 14 + 15 + export const zPostFooData = z.object({ 16 + body: z.optional(z.never()), 17 + path: z.optional(z.never()), 18 + query: z.optional(z.never()) 19 + }); 20 + 21 + /** 22 + * OK 23 + */ 24 + export const zPostFooResponse = zFoo;
+741
packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v3/default/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod/v3'; 4 + 5 + /** 6 + * Testing multiline comments in string: First line 7 + * Second line 8 + * 9 + * Fourth line 10 + */ 11 + export const zCommentWithBreaks = z.number().int(); 12 + 13 + /** 14 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 15 + */ 16 + export const zCommentWithBackticks = z.number().int(); 17 + 18 + /** 19 + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 20 + */ 21 + export const zCommentWithBackticksAndQuotes = z.number().int(); 22 + 23 + /** 24 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 25 + */ 26 + export const zCommentWithSlashes = z.number().int(); 27 + 28 + /** 29 + * Testing expression placeholders in string: ${expression} should work 30 + */ 31 + export const zCommentWithExpressionPlaceholders = z.number().int(); 32 + 33 + /** 34 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 35 + */ 36 + export const zCommentWithQuotes = z.number().int(); 37 + 38 + /** 39 + * Testing reserved characters in string: * inline * and ** inline ** should work 40 + */ 41 + export const zCommentWithReservedCharacters = z.number().int(); 42 + 43 + /** 44 + * This is a simple number 45 + */ 46 + export const zSimpleInteger = z.number().int(); 47 + 48 + /** 49 + * This is a simple boolean 50 + */ 51 + export const zSimpleBoolean = z.boolean(); 52 + 53 + /** 54 + * This is a simple string 55 + */ 56 + export const zSimpleString = z.string(); 57 + 58 + /** 59 + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 60 + */ 61 + export const zNonAsciiStringæøåÆøÅöôêÊ字符串 = z.string(); 62 + 63 + /** 64 + * This is a simple file 65 + */ 66 + export const zSimpleFile = z.string(); 67 + 68 + /** 69 + * This is a model with one string property 70 + */ 71 + export const zModelWithString = z.object({ 72 + prop: z.string().optional() 73 + }); 74 + 75 + export const zSimpleReference = zModelWithString; 76 + 77 + /** 78 + * This is a simple string 79 + */ 80 + export const zSimpleStringWithPattern = z.string().max(64).regex(/^[a-zA-Z0-9_]*$/); 81 + 82 + /** 83 + * This is a simple enum with strings 84 + */ 85 + export const zEnumWithStrings = z.enum([ 86 + 'Success', 87 + 'Warning', 88 + 'Error', 89 + "'Single Quote'", 90 + '"Double Quotes"', 91 + 'Non-ascii: øæåôöØÆÅÔÖ字符串' 92 + ]); 93 + 94 + /** 95 + * This is a simple enum with numbers 96 + */ 97 + export const zEnumWithNumbers = z.unknown(); 98 + 99 + /** 100 + * Success=1,Warning=2,Error=3 101 + */ 102 + export const zEnumFromDescription = z.number(); 103 + 104 + /** 105 + * This is a simple enum with numbers 106 + */ 107 + export const zEnumWithExtensions = z.unknown(); 108 + 109 + /** 110 + * This is a simple array with numbers 111 + */ 112 + export const zArrayWithNumbers = z.array(z.number().int()); 113 + 114 + /** 115 + * This is a simple array with booleans 116 + */ 117 + export const zArrayWithBooleans = z.array(z.boolean()); 118 + 119 + /** 120 + * This is a simple array with strings 121 + */ 122 + export const zArrayWithStrings = z.array(z.string()); 123 + 124 + /** 125 + * This is a simple array with references 126 + */ 127 + export const zArrayWithReferences = z.array(zModelWithString); 128 + 129 + /** 130 + * This is a simple array containing an array 131 + */ 132 + export const zArrayWithArray = z.array(z.array(zModelWithString)); 133 + 134 + /** 135 + * This is a simple array with properties 136 + */ 137 + export const zArrayWithProperties = z.array(z.object({ 138 + foo: z.string().optional(), 139 + bar: z.string().optional() 140 + })); 141 + 142 + /** 143 + * This is a string dictionary 144 + */ 145 + export const zDictionaryWithString = z.object({}); 146 + 147 + /** 148 + * This is a string reference 149 + */ 150 + export const zDictionaryWithReference = z.object({}); 151 + 152 + /** 153 + * This is a complex dictionary 154 + */ 155 + export const zDictionaryWithArray = z.object({}); 156 + 157 + /** 158 + * This is a string dictionary 159 + */ 160 + export const zDictionaryWithDictionary = z.record(z.object({})); 161 + 162 + /** 163 + * This is a complex dictionary 164 + */ 165 + export const zDictionaryWithProperties = z.record(z.object({ 166 + foo: z.string().optional(), 167 + bar: z.string().optional() 168 + })); 169 + 170 + /** 171 + * This is a type-only model that defines Date as a string 172 + */ 173 + export const zDate = z.string(); 174 + 175 + /** 176 + * This is a model with one number property 177 + */ 178 + export const zModelWithInteger = z.object({ 179 + prop: z.number().int().optional() 180 + }); 181 + 182 + /** 183 + * This is a model with one boolean property 184 + */ 185 + export const zModelWithBoolean = z.object({ 186 + prop: z.boolean().optional() 187 + }); 188 + 189 + /** 190 + * This is a model with one string property 191 + */ 192 + export const zModelWithStringError = z.object({ 193 + prop: z.string().optional() 194 + }); 195 + 196 + /** 197 + * This is a model with one string property 198 + */ 199 + export const zModelWithNullableString = z.object({ 200 + nullableProp: z.union([ 201 + z.string(), 202 + z.null() 203 + ]).optional(), 204 + nullableRequiredProp: z.union([ 205 + z.string(), 206 + z.null() 207 + ]) 208 + }); 209 + 210 + /** 211 + * This is a model with one enum 212 + */ 213 + export const zModelWithEnum = z.object({ 214 + test: z.enum([ 215 + 'Success', 216 + 'Warning', 217 + 'Error', 218 + 'ØÆÅ字符串' 219 + ]).optional(), 220 + statusCode: z.enum([ 221 + '100', 222 + '200 FOO', 223 + '300 FOO_BAR', 224 + '400 foo-bar', 225 + '500 foo.bar', 226 + '600 foo&bar' 227 + ]).optional(), 228 + bool: z.unknown().optional() 229 + }); 230 + 231 + /** 232 + * This is a model with one enum 233 + */ 234 + export const zModelWithEnumFromDescription = z.object({ 235 + test: z.number().int().optional() 236 + }); 237 + 238 + /** 239 + * This is a model with nested enums 240 + */ 241 + export const zModelWithNestedEnums = z.object({ 242 + dictionaryWithEnum: z.object({}).optional(), 243 + dictionaryWithEnumFromDescription: z.object({}).optional(), 244 + arrayWithEnum: z.array(z.enum([ 245 + 'Success', 246 + 'Warning', 247 + 'Error' 248 + ])).optional(), 249 + arrayWithDescription: z.array(z.number().int()).optional() 250 + }); 251 + 252 + /** 253 + * This is a model with one nested property 254 + */ 255 + export const zModelWithProperties = z.object({ 256 + required: z.string(), 257 + requiredAndReadOnly: z.string().readonly(), 258 + string: z.string().optional(), 259 + number: z.number().optional(), 260 + boolean: z.boolean().optional(), 261 + reference: zModelWithString.optional(), 262 + 'property with space': z.string().optional(), 263 + default: z.string().optional(), 264 + try: z.string().optional(), 265 + '@namespace.string': z.string().readonly().optional(), 266 + '@namespace.integer': z.number().int().readonly().optional() 267 + }); 268 + 269 + /** 270 + * This is a model with one property containing a reference 271 + */ 272 + export const zModelWithReference = z.object({ 273 + prop: zModelWithProperties.optional() 274 + }); 275 + 276 + /** 277 + * This is a model with one property containing an array 278 + */ 279 + export const zModelWithArray = z.object({ 280 + prop: z.array(zModelWithString).optional(), 281 + propWithFile: z.array(z.string()).optional(), 282 + propWithNumber: z.array(z.number()).optional() 283 + }); 284 + 285 + /** 286 + * This is a model with one property containing a dictionary 287 + */ 288 + export const zModelWithDictionary = z.object({ 289 + prop: z.object({}).optional() 290 + }); 291 + 292 + /** 293 + * This is a model with one property containing a circular reference 294 + */ 295 + export const zModelWithCircularReference: z.AnyZodObject = z.object({ 296 + prop: z.lazy(() => { 297 + return zModelWithCircularReference; 298 + }).optional() 299 + }); 300 + 301 + /** 302 + * This is a model with one nested property 303 + */ 304 + export const zModelWithNestedProperties = z.object({ 305 + first: z.object({ 306 + second: z.object({ 307 + third: z.string().readonly() 308 + }).readonly() 309 + }).readonly() 310 + }); 311 + 312 + /** 313 + * This is a model with duplicated properties 314 + */ 315 + export const zModelWithDuplicateProperties = z.object({ 316 + prop: zModelWithString.optional() 317 + }); 318 + 319 + /** 320 + * This is a model with ordered properties 321 + */ 322 + export const zModelWithOrderedProperties = z.object({ 323 + zebra: z.string().optional(), 324 + apple: z.string().optional(), 325 + hawaii: z.string().optional() 326 + }); 327 + 328 + /** 329 + * This is a model with duplicated imports 330 + */ 331 + export const zModelWithDuplicateImports = z.object({ 332 + propA: zModelWithString.optional(), 333 + propB: zModelWithString.optional(), 334 + propC: zModelWithString.optional() 335 + }); 336 + 337 + /** 338 + * This is a model that extends another model 339 + */ 340 + export const zModelThatExtends = zModelWithString.and(z.object({ 341 + propExtendsA: z.string().optional(), 342 + propExtendsB: zModelWithString.optional() 343 + })); 344 + 345 + /** 346 + * This is a model that extends another model 347 + */ 348 + export const zModelThatExtendsExtends = zModelWithString.and(zModelThatExtends).and(z.object({ 349 + propExtendsC: z.string().optional(), 350 + propExtendsD: zModelWithString.optional() 351 + })); 352 + 353 + export const zDefault = z.object({ 354 + name: z.string().optional() 355 + }); 356 + 357 + /** 358 + * This is a model that contains a some patterns 359 + */ 360 + export const zModelWithPattern = z.object({ 361 + key: z.string().max(64).regex(/^[a-zA-Z0-9_]*$/), 362 + name: z.string().max(255), 363 + enabled: z.boolean().readonly().optional(), 364 + modified: z.string().datetime().readonly().optional(), 365 + id: z.string().regex(/^\d{2}-\d{3}-\d{4}$/).optional(), 366 + text: z.string().regex(/^\w+$/).optional(), 367 + patternWithSingleQuotes: z.string().regex(/^[a-zA-Z0-9']*$/).optional(), 368 + patternWithNewline: z.string().regex(/aaa\nbbb/).optional(), 369 + patternWithBacktick: z.string().regex(/aaa`bbb/).optional() 370 + }); 371 + 372 + export const zParameterActivityParams = z.object({ 373 + description: z.string().optional(), 374 + graduate_id: z.number().int().optional(), 375 + organization_id: z.number().int().optional(), 376 + parent_activity: z.number().int().optional(), 377 + post_id: z.number().int().optional() 378 + }); 379 + 380 + export const zResponsePostActivityResponse = z.object({ 381 + description: z.string().optional(), 382 + graduate_id: z.number().int().optional(), 383 + organization_id: z.number().int().optional(), 384 + parent_activity_id: z.number().int().optional(), 385 + post_id: z.number().int().optional() 386 + }); 387 + 388 + export const zFailureFailure = z.object({ 389 + error: z.string().optional(), 390 + message: z.string().optional(), 391 + reference_code: z.string().optional() 392 + }); 393 + 394 + export const zServiceWithEmptyTagData = z.object({ 395 + body: z.never().optional(), 396 + path: z.never().optional(), 397 + query: z.never().optional() 398 + }); 399 + 400 + export const zPatchApiVbyApiVersionNoTagData = z.object({ 401 + body: z.never().optional(), 402 + path: z.never().optional(), 403 + query: z.never().optional() 404 + }); 405 + 406 + export const zFooWowData = z.object({ 407 + body: z.never().optional(), 408 + path: z.never().optional(), 409 + query: z.never().optional() 410 + }); 411 + 412 + export const zDeleteCallWithoutParametersAndResponseData = z.object({ 413 + body: z.never().optional(), 414 + path: z.never().optional(), 415 + query: z.never().optional() 416 + }); 417 + 418 + export const zGetCallWithoutParametersAndResponseData = z.object({ 419 + body: z.never().optional(), 420 + path: z.never().optional(), 421 + query: z.never().optional() 422 + }); 423 + 424 + export const zHeadCallWithoutParametersAndResponseData = z.object({ 425 + body: z.never().optional(), 426 + path: z.never().optional(), 427 + query: z.never().optional() 428 + }); 429 + 430 + export const zOptionsCallWithoutParametersAndResponseData = z.object({ 431 + body: z.never().optional(), 432 + path: z.never().optional(), 433 + query: z.never().optional() 434 + }); 435 + 436 + export const zPatchCallWithoutParametersAndResponseData = z.object({ 437 + body: z.never().optional(), 438 + path: z.never().optional(), 439 + query: z.never().optional() 440 + }); 441 + 442 + export const zPostCallWithoutParametersAndResponseData = z.object({ 443 + body: z.never().optional(), 444 + path: z.never().optional(), 445 + query: z.never().optional() 446 + }); 447 + 448 + export const zPutCallWithoutParametersAndResponseData = z.object({ 449 + body: z.never().optional(), 450 + path: z.never().optional(), 451 + query: z.never().optional() 452 + }); 453 + 454 + export const zCallWithDescriptionsData = z.object({ 455 + body: z.never().optional(), 456 + path: z.never().optional(), 457 + query: z.object({ 458 + parameterWithBreaks: z.string().optional(), 459 + parameterWithBackticks: z.string().optional(), 460 + parameterWithSlashes: z.string().optional(), 461 + parameterWithExpressionPlaceholders: z.string().optional(), 462 + parameterWithQuotes: z.string().optional(), 463 + parameterWithReservedCharacters: z.string().optional() 464 + }).optional() 465 + }); 466 + 467 + export const zCallWithParametersData = z.object({ 468 + body: z.never().optional(), 469 + path: z.object({ 470 + parameterPath: z.string(), 471 + 'api-version': z.string() 472 + }), 473 + query: z.object({ 474 + parameterQuery: z.string() 475 + }), 476 + headers: z.object({ 477 + parameterHeader: z.string() 478 + }) 479 + }); 480 + 481 + export const zCallWithWeirdParameterNamesData = z.object({ 482 + body: z.never().optional(), 483 + path: z.object({ 484 + 'parameter.path.1': z.string().optional(), 485 + 'parameter-path-2': z.string().optional(), 486 + 'PARAMETER-PATH-3': z.string().optional(), 487 + 'api-version': z.string() 488 + }), 489 + query: z.object({ 490 + default: z.string().optional(), 491 + 'parameter-query': z.string() 492 + }), 493 + headers: z.object({ 494 + 'parameter.header': z.string() 495 + }) 496 + }); 497 + 498 + export const zCallWithDefaultParametersData = z.object({ 499 + body: z.never().optional(), 500 + path: z.never().optional(), 501 + query: z.object({ 502 + parameterString: z.string().default('Hello World!'), 503 + parameterNumber: z.number().default(123), 504 + parameterBoolean: z.boolean().default(true), 505 + parameterEnum: z.enum([ 506 + 'Success', 507 + 'Warning', 508 + 'Error' 509 + ]), 510 + parameterModel: z.object({ 511 + prop: z.string().optional() 512 + }).default({ 513 + prop: 'Hello World!' 514 + }) 515 + }) 516 + }); 517 + 518 + export const zCallWithDefaultOptionalParametersData = z.object({ 519 + body: z.never().optional(), 520 + path: z.never().optional(), 521 + query: z.object({ 522 + parameterString: z.string().optional().default('Hello World!'), 523 + parameterNumber: z.number().optional().default(123), 524 + parameterBoolean: z.boolean().optional().default(true), 525 + parameterEnum: z.enum([ 526 + 'Success', 527 + 'Warning', 528 + 'Error' 529 + ]).optional() 530 + }).optional() 531 + }); 532 + 533 + export const zCallToTestOrderOfParamsData = z.object({ 534 + body: z.never().optional(), 535 + path: z.never().optional(), 536 + query: z.object({ 537 + parameterOptionalStringWithDefault: z.string().optional().default('Hello World!'), 538 + parameterOptionalStringWithEmptyDefault: z.string().optional().default(''), 539 + parameterOptionalStringWithNoDefault: z.string().optional(), 540 + parameterStringWithDefault: z.string().default('Hello World!'), 541 + parameterStringWithEmptyDefault: z.string().default(''), 542 + parameterStringWithNoDefault: z.string(), 543 + parameterStringNullableWithNoDefault: z.union([ 544 + z.string(), 545 + z.null() 546 + ]).optional(), 547 + parameterStringNullableWithDefault: z.union([ 548 + z.string(), 549 + z.null() 550 + ]).optional().default(null) 551 + }) 552 + }); 553 + 554 + export const zDuplicateNameData = z.object({ 555 + body: z.never().optional(), 556 + path: z.never().optional(), 557 + query: z.never().optional() 558 + }); 559 + 560 + export const zDuplicateName2Data = z.object({ 561 + body: z.never().optional(), 562 + path: z.never().optional(), 563 + query: z.never().optional() 564 + }); 565 + 566 + export const zDuplicateName3Data = z.object({ 567 + body: z.never().optional(), 568 + path: z.never().optional(), 569 + query: z.never().optional() 570 + }); 571 + 572 + export const zDuplicateName4Data = z.object({ 573 + body: z.never().optional(), 574 + path: z.never().optional(), 575 + query: z.never().optional() 576 + }); 577 + 578 + export const zCallWithNoContentResponseData = z.object({ 579 + body: z.never().optional(), 580 + path: z.never().optional(), 581 + query: z.never().optional() 582 + }); 583 + 584 + export const zCallWithResponseAndNoContentResponseData = z.object({ 585 + body: z.never().optional(), 586 + path: z.never().optional(), 587 + query: z.never().optional() 588 + }); 589 + 590 + export const zCallWithResponseAndNoContentResponseResponse = z.union([ 591 + z.number(), 592 + z.unknown() 593 + ]); 594 + 595 + export const zDummyAData = z.object({ 596 + body: z.never().optional(), 597 + path: z.never().optional(), 598 + query: z.never().optional() 599 + }); 600 + 601 + export const zDummyBData = z.object({ 602 + body: z.never().optional(), 603 + path: z.never().optional(), 604 + query: z.never().optional() 605 + }); 606 + 607 + export const zCallWithResponseData = z.object({ 608 + body: z.never().optional(), 609 + path: z.never().optional(), 610 + query: z.never().optional() 611 + }); 612 + 613 + /** 614 + * Message for default response 615 + */ 616 + export const zCallWithResponseResponse = zModelWithString; 617 + 618 + export const zCallWithDuplicateResponsesData = z.object({ 619 + body: z.never().optional(), 620 + path: z.never().optional(), 621 + query: z.never().optional() 622 + }); 623 + 624 + /** 625 + * Message for 201 response 626 + */ 627 + export const zCallWithDuplicateResponsesResponse = zModelWithString; 628 + 629 + export const zCallWithResponsesData = z.object({ 630 + body: z.never().optional(), 631 + path: z.never().optional(), 632 + query: z.never().optional() 633 + }); 634 + 635 + export const zCallWithResponsesResponse = z.union([ 636 + z.object({ 637 + '@namespace.string': z.string().readonly().optional(), 638 + '@namespace.integer': z.number().int().readonly().optional(), 639 + value: z.array(zModelWithString).readonly().optional() 640 + }), 641 + zModelThatExtends, 642 + zModelThatExtendsExtends 643 + ]); 644 + 645 + export const zCollectionFormatData = z.object({ 646 + body: z.never().optional(), 647 + path: z.never().optional(), 648 + query: z.object({ 649 + parameterArrayCSV: z.array(z.string()), 650 + parameterArraySSV: z.array(z.string()), 651 + parameterArrayTSV: z.array(z.string()), 652 + parameterArrayPipes: z.array(z.string()), 653 + parameterArrayMulti: z.array(z.string()) 654 + }) 655 + }); 656 + 657 + export const zTypesData = z.object({ 658 + body: z.never().optional(), 659 + path: z.object({ 660 + id: z.number().int().optional() 661 + }).optional(), 662 + query: z.object({ 663 + parameterNumber: z.number().default(123), 664 + parameterString: z.string().default('default'), 665 + parameterBoolean: z.boolean().default(true), 666 + parameterArray: z.array(z.string()), 667 + parameterDictionary: z.object({}), 668 + parameterEnum: z.enum([ 669 + 'Success', 670 + 'Warning', 671 + 'Error' 672 + ]) 673 + }) 674 + }); 675 + 676 + export const zTypesResponse = z.union([ 677 + z.number(), 678 + z.string(), 679 + z.boolean(), 680 + z.object({}) 681 + ]); 682 + 683 + export const zComplexTypesData = z.object({ 684 + body: z.never().optional(), 685 + path: z.never().optional(), 686 + query: z.object({ 687 + parameterObject: z.object({ 688 + first: z.object({ 689 + second: z.object({ 690 + third: z.string().optional() 691 + }).optional() 692 + }).optional() 693 + }), 694 + parameterReference: z.object({ 695 + prop: z.string().optional() 696 + }) 697 + }) 698 + }); 699 + 700 + /** 701 + * Successful response 702 + */ 703 + export const zComplexTypesResponse = z.array(zModelWithString); 704 + 705 + export const zCallWithResultFromHeaderData = z.object({ 706 + body: z.never().optional(), 707 + path: z.never().optional(), 708 + query: z.never().optional() 709 + }); 710 + 711 + export const zTestErrorCodeData = z.object({ 712 + body: z.never().optional(), 713 + path: z.never().optional(), 714 + query: z.object({ 715 + status: z.string() 716 + }) 717 + }); 718 + 719 + export const zNonAsciiæøåÆøÅöôêÊ字符串Data = z.object({ 720 + body: z.never().optional(), 721 + path: z.never().optional(), 722 + query: z.object({ 723 + 'nonAsciiParamæøåÆØÅöôêÊ': z.number().int() 724 + }) 725 + }); 726 + 727 + /** 728 + * Successful response 729 + */ 730 + export const zNonAsciiæøåÆøÅöôêÊ字符串Response = zNonAsciiStringæøåÆøÅöôêÊ字符串; 731 + 732 + export const zPostApiVbyApiVersionBodyData = z.object({ 733 + body: zParameterActivityParams, 734 + path: z.never().optional(), 735 + query: z.never().optional() 736 + }); 737 + 738 + /** 739 + * OK 740 + */ 741 + export const zPostApiVbyApiVersionBodyResponse = zResponsePostActivityResponse;
+24
packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v3/type-format-zod/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod/v3'; 4 + 5 + export const zFoo = z.object({ 6 + bar: z.number().int().optional(), 7 + foo: z.coerce.bigint().default(BigInt(0)), 8 + id: z.string() 9 + }); 10 + 11 + export const zBar = z.object({ 12 + foo: z.number().int() 13 + }); 14 + 15 + export const zPostFooData = z.object({ 16 + body: z.never().optional(), 17 + path: z.never().optional(), 18 + query: z.never().optional() 19 + }); 20 + 21 + /** 22 + * OK 23 + */ 24 + export const zPostFooResponse = zFoo;
+24
packages/openapi-ts-tests/zod/v4/__snapshots__/2.0.x/v4/type-format-zod/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod'; 4 + 5 + export const zFoo = z.object({ 6 + bar: z.optional(z.int()), 7 + foo: z.coerce.bigint().default(BigInt(0)), 8 + id: z.string() 9 + }); 10 + 11 + export const zBar = z.object({ 12 + foo: z.int() 13 + }); 14 + 15 + export const zPostFooData = z.object({ 16 + body: z.optional(z.never()), 17 + path: z.optional(z.never()), 18 + query: z.optional(z.never()) 19 + }); 20 + 21 + /** 22 + * OK 23 + */ 24 + export const zPostFooResponse = zFoo;
+9
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/array-items-one-of-length-1/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as z from 'zod/mini'; 4 + 5 + export const zBar = z.string(); 6 + 7 + export const zFoo = z.object({ 8 + foo: z.optional(z.array(zBar).check(z.minLength(1), z.maxLength(2147483647))) 9 + });
+1986
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/default/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as z from 'zod/mini'; 4 + 5 + /** 6 + * Model with number-only name 7 + */ 8 + export const z400 = z.string(); 9 + 10 + /** 11 + * Testing multiline comments in string: First line 12 + * Second line 13 + * 14 + * Fourth line 15 + */ 16 + export const zCamelCaseCommentWithBreaks = z.int(); 17 + 18 + /** 19 + * Testing multiline comments in string: First line 20 + * Second line 21 + * 22 + * Fourth line 23 + */ 24 + export const zCommentWithBreaks = z.int(); 25 + 26 + /** 27 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 28 + */ 29 + export const zCommentWithBackticks = z.int(); 30 + 31 + /** 32 + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 33 + */ 34 + export const zCommentWithBackticksAndQuotes = z.int(); 35 + 36 + /** 37 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 38 + */ 39 + export const zCommentWithSlashes = z.int(); 40 + 41 + /** 42 + * Testing expression placeholders in string: ${expression} should work 43 + */ 44 + export const zCommentWithExpressionPlaceholders = z.int(); 45 + 46 + /** 47 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 48 + */ 49 + export const zCommentWithQuotes = z.int(); 50 + 51 + /** 52 + * Testing reserved characters in string: * inline * and ** inline ** should work 53 + */ 54 + export const zCommentWithReservedCharacters = z.int(); 55 + 56 + /** 57 + * This is a simple number 58 + */ 59 + export const zSimpleInteger = z.int(); 60 + 61 + /** 62 + * This is a simple boolean 63 + */ 64 + export const zSimpleBoolean = z.boolean(); 65 + 66 + /** 67 + * This is a simple string 68 + */ 69 + export const zSimpleString = z.string(); 70 + 71 + /** 72 + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 73 + */ 74 + export const zNonAsciiStringæøåÆøÅöôêÊ字符串 = z.string(); 75 + 76 + /** 77 + * This is a simple file 78 + */ 79 + export const zSimpleFile = z.string(); 80 + 81 + /** 82 + * This is a model with one string property 83 + */ 84 + export const zModelWithString = z.object({ 85 + prop: z.optional(z.string()) 86 + }); 87 + 88 + /** 89 + * This is a simple reference 90 + */ 91 + export const zSimpleReference = zModelWithString; 92 + 93 + /** 94 + * This is a simple string 95 + */ 96 + export const zSimpleStringWithPattern = z.union([ 97 + z.string().check(z.maxLength(64), z.regex(/^[a-zA-Z0-9_]*$/)), 98 + z.null() 99 + ]); 100 + 101 + /** 102 + * This is a simple enum with strings 103 + */ 104 + export const zEnumWithStrings = z.enum([ 105 + 'Success', 106 + 'Warning', 107 + 'Error', 108 + "'Single Quote'", 109 + '"Double Quotes"', 110 + 'Non-ascii: øæåôöØÆÅÔÖ字符串' 111 + ]); 112 + 113 + export const zEnumWithReplacedCharacters = z.enum([ 114 + "'Single Quote'", 115 + '"Double Quotes"', 116 + 'øæåôöØÆÅÔÖ字符串', 117 + '' 118 + ]); 119 + 120 + /** 121 + * This is a simple enum with numbers 122 + */ 123 + export const zEnumWithNumbers = z.unknown(); 124 + 125 + /** 126 + * Success=1,Warning=2,Error=3 127 + */ 128 + export const zEnumFromDescription = z.number(); 129 + 130 + /** 131 + * This is a simple enum with numbers 132 + */ 133 + export const zEnumWithExtensions = z.unknown(); 134 + 135 + export const zEnumWithXEnumNames = z.unknown(); 136 + 137 + /** 138 + * This is a simple array with numbers 139 + */ 140 + export const zArrayWithNumbers = z.array(z.int()); 141 + 142 + /** 143 + * This is a simple array with booleans 144 + */ 145 + export const zArrayWithBooleans = z.array(z.boolean()); 146 + 147 + /** 148 + * This is a simple array with strings 149 + */ 150 + export const zArrayWithStrings = z._default(z.array(z.string()), ['test']); 151 + 152 + /** 153 + * This is a simple array with references 154 + */ 155 + export const zArrayWithReferences = z.array(zModelWithString); 156 + 157 + /** 158 + * This is a simple array containing an array 159 + */ 160 + export const zArrayWithArray = z.array(z.array(zModelWithString)); 161 + 162 + /** 163 + * This is a simple array with properties 164 + */ 165 + export const zArrayWithProperties = z.array(z.object({ 166 + '16x16': z.optional(zCamelCaseCommentWithBreaks), 167 + bar: z.optional(z.string()) 168 + })); 169 + 170 + /** 171 + * This is a simple array with any of properties 172 + */ 173 + export const zArrayWithAnyOfProperties = z.array(z.union([ 174 + z.object({ 175 + foo: z._default(z.optional(z.string()), 'test') 176 + }), 177 + z.object({ 178 + bar: z.optional(z.string()) 179 + }) 180 + ])); 181 + 182 + export const zAnyOfAnyAndNull = z.object({ 183 + data: z.optional(z.unknown()) 184 + }); 185 + 186 + /** 187 + * This is a simple array with any of properties 188 + */ 189 + export const zAnyOfArrays = z.object({ 190 + results: z.optional(z.array(z.union([ 191 + z.object({ 192 + foo: z.optional(z.string()) 193 + }), 194 + z.object({ 195 + bar: z.optional(z.string()) 196 + }) 197 + ]))) 198 + }); 199 + 200 + /** 201 + * This is a string dictionary 202 + */ 203 + export const zDictionaryWithString = z.object({}); 204 + 205 + export const zDictionaryWithPropertiesAndAdditionalProperties = z.object({ 206 + foo: z.optional(z.number()), 207 + bar: z.optional(z.boolean()) 208 + }); 209 + 210 + /** 211 + * This is a string reference 212 + */ 213 + export const zDictionaryWithReference = z.object({}); 214 + 215 + /** 216 + * This is a complex dictionary 217 + */ 218 + export const zDictionaryWithArray = z.object({}); 219 + 220 + /** 221 + * This is a string dictionary 222 + */ 223 + export const zDictionaryWithDictionary = z.record(z.string(), z.object({})); 224 + 225 + /** 226 + * This is a complex dictionary 227 + */ 228 + export const zDictionaryWithProperties = z.record(z.string(), z.object({ 229 + foo: z.optional(z.string()), 230 + bar: z.optional(z.string()) 231 + })); 232 + 233 + /** 234 + * This is a model with one number property 235 + */ 236 + export const zModelWithInteger = z.object({ 237 + prop: z.optional(z.int()) 238 + }); 239 + 240 + /** 241 + * This is a model with one boolean property 242 + */ 243 + export const zModelWithBoolean = z.object({ 244 + prop: z.optional(z.boolean()) 245 + }); 246 + 247 + /** 248 + * This is a model with one string property 249 + */ 250 + export const zModelWithStringError = z.object({ 251 + prop: z.optional(z.string()) 252 + }); 253 + 254 + /** 255 + * `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) 256 + */ 257 + export const zModelFromZendesk = z.string(); 258 + 259 + /** 260 + * This is a model with one string property 261 + */ 262 + export const zModelWithNullableString = z.object({ 263 + nullableProp1: z.optional(z.union([ 264 + z.string(), 265 + z.null() 266 + ])), 267 + nullableRequiredProp1: z.union([ 268 + z.string(), 269 + z.null() 270 + ]), 271 + nullableProp2: z.optional(z.union([ 272 + z.string(), 273 + z.null() 274 + ])), 275 + nullableRequiredProp2: z.union([ 276 + z.string(), 277 + z.null() 278 + ]), 279 + 'foo_bar-enum': z.optional(z.enum([ 280 + 'Success', 281 + 'Warning', 282 + 'Error', 283 + 'ØÆÅ字符串' 284 + ])) 285 + }); 286 + 287 + /** 288 + * This is a model with one enum 289 + */ 290 + export const zModelWithEnum = z.object({ 291 + 'foo_bar-enum': z.optional(z.enum([ 292 + 'Success', 293 + 'Warning', 294 + 'Error', 295 + 'ØÆÅ字符串' 296 + ])), 297 + statusCode: z.optional(z.enum([ 298 + '100', 299 + '200 FOO', 300 + '300 FOO_BAR', 301 + '400 foo-bar', 302 + '500 foo.bar', 303 + '600 foo&bar' 304 + ])), 305 + bool: z.optional(z.unknown()) 306 + }); 307 + 308 + /** 309 + * This is a model with one enum with escaped name 310 + */ 311 + export const zModelWithEnumWithHyphen = z.object({ 312 + 'foo-bar-baz-qux': z.optional(z.enum([ 313 + '3.0' 314 + ])) 315 + }); 316 + 317 + /** 318 + * This is a model with one enum 319 + */ 320 + export const zModelWithEnumFromDescription = z.object({ 321 + test: z.optional(z.int()) 322 + }); 323 + 324 + /** 325 + * This is a model with nested enums 326 + */ 327 + export const zModelWithNestedEnums = z.object({ 328 + dictionaryWithEnum: z.optional(z.object({})), 329 + dictionaryWithEnumFromDescription: z.optional(z.object({})), 330 + arrayWithEnum: z.optional(z.array(z.enum([ 331 + 'Success', 332 + 'Warning', 333 + 'Error' 334 + ]))), 335 + arrayWithDescription: z.optional(z.array(z.int())), 336 + 'foo_bar-enum': z.optional(z.enum([ 337 + 'Success', 338 + 'Warning', 339 + 'Error', 340 + 'ØÆÅ字符串' 341 + ])) 342 + }); 343 + 344 + /** 345 + * This is a model with one nested property 346 + */ 347 + export const zModelWithProperties = z.object({ 348 + required: z.string(), 349 + requiredAndReadOnly: z.readonly(z.string()), 350 + requiredAndNullable: z.union([ 351 + z.string(), 352 + z.null() 353 + ]), 354 + string: z.optional(z.string()), 355 + number: z.optional(z.number()), 356 + boolean: z.optional(z.boolean()), 357 + reference: z.optional(zModelWithString), 358 + 'property with space': z.optional(z.string()), 359 + default: z.optional(z.string()), 360 + try: z.optional(z.string()), 361 + '@namespace.string': z.optional(z.readonly(z.string())), 362 + '@namespace.integer': z.optional(z.readonly(z.int())) 363 + }); 364 + 365 + /** 366 + * This is a model with one property containing a reference 367 + */ 368 + export const zModelWithReference = z.object({ 369 + prop: z.optional(zModelWithProperties) 370 + }); 371 + 372 + export const zModelWithReadOnlyAndWriteOnly = z.object({ 373 + foo: z.string(), 374 + bar: z.readonly(z.string()) 375 + }); 376 + 377 + /** 378 + * This is a model with one property containing an array 379 + */ 380 + export const zModelWithArrayReadOnlyAndWriteOnly = z.object({ 381 + prop: z.optional(z.array(zModelWithReadOnlyAndWriteOnly)), 382 + propWithFile: z.optional(z.array(z.string())), 383 + propWithNumber: z.optional(z.array(z.number())) 384 + }); 385 + 386 + /** 387 + * This is a model with one property containing an array 388 + */ 389 + export const zModelWithArray = z.object({ 390 + prop: z.optional(z.array(zModelWithString)), 391 + propWithFile: z.optional(z.array(z.string())), 392 + propWithNumber: z.optional(z.array(z.number())) 393 + }); 394 + 395 + /** 396 + * This is a model with one property containing a dictionary 397 + */ 398 + export const zModelWithDictionary = z.object({ 399 + prop: z.optional(z.object({})) 400 + }); 401 + 402 + /** 403 + * This is a deprecated model with a deprecated property 404 + * @deprecated 405 + */ 406 + export const zDeprecatedModel = z.object({ 407 + prop: z.optional(z.string()) 408 + }); 409 + 410 + /** 411 + * This is a model with one property containing a circular reference 412 + */ 413 + export const zModelWithCircularReference = z.object({ 414 + get prop(): z.ZodMiniOptional { 415 + return z.optional(z.lazy((): any => { 416 + return zModelWithCircularReference; 417 + })); 418 + } 419 + }); 420 + 421 + /** 422 + * This is a model with one property with a 'one of' relationship 423 + */ 424 + export const zCompositionWithOneOf = z.object({ 425 + propA: z.optional(z.union([ 426 + zModelWithString, 427 + zModelWithEnum, 428 + zModelWithArray, 429 + zModelWithDictionary 430 + ])) 431 + }); 432 + 433 + /** 434 + * This is a model with one property with a 'one of' relationship where the options are not $ref 435 + */ 436 + export const zCompositionWithOneOfAnonymous = z.object({ 437 + propA: z.optional(z.union([ 438 + z.object({ 439 + propA: z.optional(z.string()) 440 + }), 441 + z.string(), 442 + z.int() 443 + ])) 444 + }); 445 + 446 + /** 447 + * Circle 448 + */ 449 + export const zModelCircle = z.object({ 450 + kind: z.string(), 451 + radius: z.optional(z.number()) 452 + }); 453 + 454 + /** 455 + * Square 456 + */ 457 + export const zModelSquare = z.object({ 458 + kind: z.string(), 459 + sideLength: z.optional(z.number()) 460 + }); 461 + 462 + /** 463 + * This is a model with one property with a 'one of' relationship where the options are not $ref 464 + */ 465 + export const zCompositionWithOneOfDiscriminator = z.union([ 466 + z.intersection(z.object({ 467 + kind: z.literal('circle') 468 + }), zModelCircle), 469 + z.intersection(z.object({ 470 + kind: z.literal('square') 471 + }), zModelSquare) 472 + ]); 473 + 474 + /** 475 + * This is a model with one property with a 'any of' relationship 476 + */ 477 + export const zCompositionWithAnyOf = z.object({ 478 + propA: z.optional(z.union([ 479 + zModelWithString, 480 + zModelWithEnum, 481 + zModelWithArray, 482 + zModelWithDictionary 483 + ])) 484 + }); 485 + 486 + /** 487 + * This is a model with one property with a 'any of' relationship where the options are not $ref 488 + */ 489 + export const zCompositionWithAnyOfAnonymous = z.object({ 490 + propA: z.optional(z.union([ 491 + z.object({ 492 + propA: z.optional(z.string()) 493 + }), 494 + z.string(), 495 + z.int() 496 + ])) 497 + }); 498 + 499 + /** 500 + * This is a model with nested 'any of' property with a type null 501 + */ 502 + export const zCompositionWithNestedAnyAndTypeNull = z.object({ 503 + propA: z.optional(z.union([ 504 + z.array(z.union([ 505 + zModelWithDictionary, 506 + z.null() 507 + ])), 508 + z.array(z.union([ 509 + zModelWithArray, 510 + z.null() 511 + ])) 512 + ])) 513 + }); 514 + 515 + export const z3eNum1Период = z.enum([ 516 + 'Bird', 517 + 'Dog' 518 + ]); 519 + 520 + export const zConstValue = z.enum([ 521 + 'ConstValue' 522 + ]); 523 + 524 + /** 525 + * This is a model with one property with a 'any of' relationship where the options are not $ref 526 + */ 527 + export const zCompositionWithNestedAnyOfAndNull = z.object({ 528 + propA: z.optional(z.union([ 529 + z.array(z.union([ 530 + z3eNum1Период, 531 + zConstValue 532 + ])), 533 + z.null() 534 + ])) 535 + }); 536 + 537 + /** 538 + * This is a model with one property with a 'one of' relationship 539 + */ 540 + export const zCompositionWithOneOfAndNullable = z.object({ 541 + propA: z.optional(z.union([ 542 + z.object({ 543 + boolean: z.optional(z.boolean()) 544 + }), 545 + zModelWithEnum, 546 + zModelWithArray, 547 + zModelWithDictionary, 548 + z.null() 549 + ])) 550 + }); 551 + 552 + /** 553 + * This is a model that contains a simple dictionary within composition 554 + */ 555 + export const zCompositionWithOneOfAndSimpleDictionary = z.object({ 556 + propA: z.optional(z.union([ 557 + z.boolean(), 558 + z.object({}) 559 + ])) 560 + }); 561 + 562 + /** 563 + * This is a model that contains a dictionary of simple arrays within composition 564 + */ 565 + export const zCompositionWithOneOfAndSimpleArrayDictionary = z.object({ 566 + propA: z.optional(z.union([ 567 + z.boolean(), 568 + z.object({}) 569 + ])) 570 + }); 571 + 572 + /** 573 + * This is a model that contains a dictionary of complex arrays (composited) within composition 574 + */ 575 + export const zCompositionWithOneOfAndComplexArrayDictionary = z.object({ 576 + propA: z.optional(z.union([ 577 + z.boolean(), 578 + z.object({}) 579 + ])) 580 + }); 581 + 582 + /** 583 + * This is a model with one property with a 'all of' relationship 584 + */ 585 + export const zCompositionWithAllOfAndNullable = z.object({ 586 + propA: z.optional(z.union([ 587 + z.intersection(z.intersection(z.intersection(z.object({ 588 + boolean: z.optional(z.boolean()) 589 + }), zModelWithEnum), zModelWithArray), zModelWithDictionary), 590 + z.null() 591 + ])) 592 + }); 593 + 594 + /** 595 + * This is a model with one property with a 'any of' relationship 596 + */ 597 + export const zCompositionWithAnyOfAndNullable = z.object({ 598 + propA: z.optional(z.union([ 599 + z.object({ 600 + boolean: z.optional(z.boolean()) 601 + }), 602 + zModelWithEnum, 603 + zModelWithArray, 604 + zModelWithDictionary, 605 + z.null() 606 + ])) 607 + }); 608 + 609 + /** 610 + * This is a base model with two simple optional properties 611 + */ 612 + export const zCompositionBaseModel = z.object({ 613 + firstName: z.optional(z.string()), 614 + lastname: z.optional(z.string()) 615 + }); 616 + 617 + /** 618 + * This is a model that extends the base model 619 + */ 620 + export const zCompositionExtendedModel = z.intersection(zCompositionBaseModel, z.object({ 621 + age: z.number(), 622 + firstName: z.string(), 623 + lastname: z.string() 624 + })); 625 + 626 + /** 627 + * This is a model with one nested property 628 + */ 629 + export const zModelWithNestedProperties = z.object({ 630 + first: z.readonly(z.union([ 631 + z.readonly(z.object({ 632 + second: z.readonly(z.union([ 633 + z.readonly(z.object({ 634 + third: z.readonly(z.union([ 635 + z.readonly(z.string()), 636 + z.null() 637 + ])) 638 + })), 639 + z.null() 640 + ])) 641 + })), 642 + z.null() 643 + ])) 644 + }); 645 + 646 + /** 647 + * This is a model with duplicated properties 648 + */ 649 + export const zModelWithDuplicateProperties = z.object({ 650 + prop: z.optional(zModelWithString) 651 + }); 652 + 653 + /** 654 + * This is a model with ordered properties 655 + */ 656 + export const zModelWithOrderedProperties = z.object({ 657 + zebra: z.optional(z.string()), 658 + apple: z.optional(z.string()), 659 + hawaii: z.optional(z.string()) 660 + }); 661 + 662 + /** 663 + * This is a model with duplicated imports 664 + */ 665 + export const zModelWithDuplicateImports = z.object({ 666 + propA: z.optional(zModelWithString), 667 + propB: z.optional(zModelWithString), 668 + propC: z.optional(zModelWithString) 669 + }); 670 + 671 + /** 672 + * This is a model that extends another model 673 + */ 674 + export const zModelThatExtends = z.intersection(zModelWithString, z.object({ 675 + propExtendsA: z.optional(z.string()), 676 + propExtendsB: z.optional(zModelWithString) 677 + })); 678 + 679 + /** 680 + * This is a model that extends another model 681 + */ 682 + export const zModelThatExtendsExtends = z.intersection(z.intersection(zModelWithString, zModelThatExtends), z.object({ 683 + propExtendsC: z.optional(z.string()), 684 + propExtendsD: z.optional(zModelWithString) 685 + })); 686 + 687 + /** 688 + * This is a model that contains a some patterns 689 + */ 690 + export const zModelWithPattern = z.object({ 691 + key: z.string().check(z.maxLength(64), z.regex(/^[a-zA-Z0-9_]*$/)), 692 + name: z.string().check(z.maxLength(255)), 693 + enabled: z.optional(z.readonly(z.boolean())), 694 + modified: z.optional(z.readonly(z.iso.datetime())), 695 + id: z.optional(z.string().check(z.regex(/^\d{2}-\d{3}-\d{4}$/))), 696 + text: z.optional(z.string().check(z.regex(/^\w+$/))), 697 + patternWithSingleQuotes: z.optional(z.string().check(z.regex(/^[a-zA-Z0-9']*$/))), 698 + patternWithNewline: z.optional(z.string().check(z.regex(/aaa\nbbb/))), 699 + patternWithBacktick: z.optional(z.string().check(z.regex(/aaa`bbb/))) 700 + }); 701 + 702 + export const zFile = z.object({ 703 + id: z.optional(z.readonly(z.string().check(z.minLength(1)))), 704 + updated_at: z.optional(z.readonly(z.iso.datetime())), 705 + created_at: z.optional(z.readonly(z.iso.datetime())), 706 + mime: z.string().check(z.minLength(1), z.maxLength(24)), 707 + file: z.optional(z.readonly(z.url())) 708 + }); 709 + 710 + export const zDefault = z.object({ 711 + name: z.optional(z.string()) 712 + }); 713 + 714 + export const zPageable = z.object({ 715 + page: z._default(z.optional(z.int().check(z.gte(0))), 0), 716 + size: z.optional(z.int().check(z.gte(1))), 717 + sort: z.optional(z.array(z.string())) 718 + }); 719 + 720 + /** 721 + * This is a free-form object without additionalProperties. 722 + */ 723 + export const zFreeFormObjectWithoutAdditionalProperties = z.object({}); 724 + 725 + /** 726 + * This is a free-form object with additionalProperties: true. 727 + */ 728 + export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.object({}); 729 + 730 + /** 731 + * This is a free-form object with additionalProperties: {}. 732 + */ 733 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.object({}); 734 + 735 + export const zModelWithConst = z.object({ 736 + String: z.optional(z.enum([ 737 + 'String' 738 + ])), 739 + number: z.optional(z.unknown()), 740 + null: z.optional(z.unknown()), 741 + withType: z.optional(z.enum([ 742 + 'Some string' 743 + ])) 744 + }); 745 + 746 + /** 747 + * This is a model with one property and additionalProperties: true 748 + */ 749 + export const zModelWithAdditionalPropertiesEqTrue = z.object({ 750 + prop: z.optional(z.string()) 751 + }); 752 + 753 + export const zNestedAnyOfArraysNullable = z.object({ 754 + nullableArray: z.optional(z.union([ 755 + z.array(z.union([ 756 + z.string(), 757 + z.boolean() 758 + ])), 759 + z.null() 760 + ])) 761 + }); 762 + 763 + /** 764 + * This is a reusable parameter 765 + */ 766 + export const zSimpleParameter = z.unknown(); 767 + 768 + export const zCompositionWithOneOfAndProperties = z.intersection(z.union([ 769 + z.object({ 770 + foo: zSimpleParameter 771 + }), 772 + z.object({ 773 + bar: zNonAsciiStringæøåÆøÅöôêÊ字符串 774 + }) 775 + ]), z.object({ 776 + baz: z.union([ 777 + z.int().check(z.gte(0)), 778 + z.null() 779 + ]), 780 + qux: z.int().check(z.gte(0)) 781 + })); 782 + 783 + /** 784 + * An object that can be null 785 + */ 786 + export const zNullableObject = z._default(z.union([ 787 + z.object({ 788 + foo: z.optional(z.string()) 789 + }), 790 + z.null() 791 + ]), null); 792 + 793 + /** 794 + * Some % character 795 + */ 796 + export const zCharactersInDescription = z.string(); 797 + 798 + export const zModelWithNullableObject = z.object({ 799 + data: z.optional(zNullableObject) 800 + }); 801 + 802 + export const zModelWithOneOfEnum = z.union([ 803 + z.object({ 804 + foo: z.enum([ 805 + 'Bar' 806 + ]) 807 + }), 808 + z.object({ 809 + foo: z.enum([ 810 + 'Baz' 811 + ]) 812 + }), 813 + z.object({ 814 + foo: z.enum([ 815 + 'Qux' 816 + ]) 817 + }), 818 + z.object({ 819 + content: z.iso.datetime(), 820 + foo: z.enum([ 821 + 'Quux' 822 + ]) 823 + }), 824 + z.object({ 825 + content: z.tuple([ 826 + z.iso.datetime(), 827 + z.iso.datetime() 828 + ]), 829 + foo: z.enum([ 830 + 'Corge' 831 + ]) 832 + }) 833 + ]); 834 + 835 + export const zModelWithNestedArrayEnumsDataFoo = z.enum([ 836 + 'foo', 837 + 'bar' 838 + ]); 839 + 840 + export const zModelWithNestedArrayEnumsDataBar = z.enum([ 841 + 'baz', 842 + 'qux' 843 + ]); 844 + 845 + export const zModelWithNestedArrayEnumsData = z.object({ 846 + foo: z.optional(z.array(zModelWithNestedArrayEnumsDataFoo)), 847 + bar: z.optional(z.array(zModelWithNestedArrayEnumsDataBar)) 848 + }); 849 + 850 + export const zModelWithNestedArrayEnums = z.object({ 851 + array_strings: z.optional(z.array(z.string())), 852 + data: z.optional(zModelWithNestedArrayEnumsData) 853 + }); 854 + 855 + export const zModelWithNestedCompositionEnums = z.object({ 856 + foo: z.optional(zModelWithNestedArrayEnumsDataFoo) 857 + }); 858 + 859 + export const zModelWithConstantSizeArray = z.tuple([ 860 + z.number(), 861 + z.number() 862 + ]); 863 + 864 + export const zModelWithAnyOfConstantSizeArray = z.tuple([ 865 + z.union([ 866 + z.number(), 867 + z.string() 868 + ]), 869 + z.union([ 870 + z.number(), 871 + z.string() 872 + ]), 873 + z.union([ 874 + z.number(), 875 + z.string() 876 + ]) 877 + ]); 878 + 879 + export const zModelWithPrefixItemsConstantSizeArray = z.array(z.union([ 880 + zModelWithInteger, 881 + z.number(), 882 + z.string() 883 + ])); 884 + 885 + export const zModelWithAnyOfConstantSizeArrayNullable = z.tuple([ 886 + z.union([ 887 + z.number(), 888 + z.null(), 889 + z.string() 890 + ]), 891 + z.union([ 892 + z.number(), 893 + z.null(), 894 + z.string() 895 + ]), 896 + z.union([ 897 + z.number(), 898 + z.null(), 899 + z.string() 900 + ]) 901 + ]); 902 + 903 + /** 904 + * Model with restricted keyword name 905 + */ 906 + export const zImport = z.string(); 907 + 908 + export const zModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = z.tuple([ 909 + z.union([ 910 + z.number(), 911 + zImport 912 + ]), 913 + z.union([ 914 + z.number(), 915 + zImport 916 + ]) 917 + ]); 918 + 919 + export const zModelWithAnyOfConstantSizeArrayAndIntersect = z.tuple([ 920 + z.intersection(z.number(), z.string()), 921 + z.intersection(z.number(), z.string()) 922 + ]); 923 + 924 + export const zModelWithNumericEnumUnion = z.object({ 925 + value: z.optional(z.unknown()) 926 + }); 927 + 928 + /** 929 + * Some description with `back ticks` 930 + */ 931 + export const zModelWithBackticksInDescription = z.object({ 932 + template: z.optional(z.string()) 933 + }); 934 + 935 + export const zModelWithOneOfAndProperties = z.intersection(z.union([ 936 + zSimpleParameter, 937 + zNonAsciiStringæøåÆøÅöôêÊ字符串 938 + ]), z.object({ 939 + baz: z.union([ 940 + z.int().check(z.gte(0)), 941 + z.null() 942 + ]), 943 + qux: z.int().check(z.gte(0)) 944 + })); 945 + 946 + /** 947 + * Model used to test deduplication strategy (unused) 948 + */ 949 + export const zParameterSimpleParameterUnused = z.string(); 950 + 951 + /** 952 + * Model used to test deduplication strategy 953 + */ 954 + export const zPostServiceWithEmptyTagResponse = z.string(); 955 + 956 + /** 957 + * Model used to test deduplication strategy 958 + */ 959 + export const zPostServiceWithEmptyTagResponse2 = z.string(); 960 + 961 + /** 962 + * Model used to test deduplication strategy 963 + */ 964 + export const zDeleteFooData = z.string(); 965 + 966 + /** 967 + * Model used to test deduplication strategy 968 + */ 969 + export const zDeleteFooData2 = z.string(); 970 + 971 + export const zSchemaWithFormRestrictedKeys = z.object({ 972 + description: z.optional(z.string()), 973 + 'x-enum-descriptions': z.optional(z.string()), 974 + 'x-enum-varnames': z.optional(z.string()), 975 + 'x-enumNames': z.optional(z.string()), 976 + title: z.optional(z.string()), 977 + object: z.optional(z.object({ 978 + description: z.optional(z.string()), 979 + 'x-enum-descriptions': z.optional(z.string()), 980 + 'x-enum-varnames': z.optional(z.string()), 981 + 'x-enumNames': z.optional(z.string()), 982 + title: z.optional(z.string()) 983 + })), 984 + array: z.optional(z.array(z.object({ 985 + description: z.optional(z.string()), 986 + 'x-enum-descriptions': z.optional(z.string()), 987 + 'x-enum-varnames': z.optional(z.string()), 988 + 'x-enumNames': z.optional(z.string()), 989 + title: z.optional(z.string()) 990 + }))) 991 + }); 992 + 993 + /** 994 + * This schema was giving PascalCase transformations a hard time 995 + */ 996 + export const zIoK8sApimachineryPkgApisMetaV1Preconditions = z.object({ 997 + resourceVersion: z.optional(z.string()), 998 + uid: z.optional(z.string()) 999 + }); 1000 + 1001 + /** 1002 + * This schema was giving PascalCase transformations a hard time 1003 + */ 1004 + export const zIoK8sApimachineryPkgApisMetaV1DeleteOptions = z.object({ 1005 + preconditions: z.optional(zIoK8sApimachineryPkgApisMetaV1Preconditions) 1006 + }); 1007 + 1008 + export const zAdditionalPropertiesUnknownIssue = z.object({}); 1009 + 1010 + export const zAdditionalPropertiesUnknownIssue2 = z.object({}); 1011 + 1012 + export const zAdditionalPropertiesUnknownIssue3 = z.intersection(z.string(), z.object({ 1013 + entries: z.object({}) 1014 + })); 1015 + 1016 + export const zAdditionalPropertiesIntegerIssue = z.object({ 1017 + value: z.int() 1018 + }); 1019 + 1020 + export const zGenericSchemaDuplicateIssue1SystemBoolean = z.object({ 1021 + item: z.optional(z.boolean()), 1022 + error: z.optional(z.union([ 1023 + z.string(), 1024 + z.null() 1025 + ])), 1026 + hasError: z.optional(z.readonly(z.boolean())), 1027 + data: z.optional(z.object({})) 1028 + }); 1029 + 1030 + export const zGenericSchemaDuplicateIssue1SystemString = z.object({ 1031 + item: z.optional(z.union([ 1032 + z.string(), 1033 + z.null() 1034 + ])), 1035 + error: z.optional(z.union([ 1036 + z.string(), 1037 + z.null() 1038 + ])), 1039 + hasError: z.optional(z.readonly(z.boolean())) 1040 + }); 1041 + 1042 + export const zOneOfAllOfIssue = z.union([ 1043 + z.intersection(z.union([ 1044 + zConstValue, 1045 + zGenericSchemaDuplicateIssue1SystemBoolean 1046 + ]), z3eNum1Период), 1047 + zGenericSchemaDuplicateIssue1SystemString 1048 + ]); 1049 + 1050 + /** 1051 + * Model with number-only name 1052 + */ 1053 + export const z400Writable = z.string(); 1054 + 1055 + /** 1056 + * Testing multiline comments in string: First line 1057 + * Second line 1058 + * 1059 + * Fourth line 1060 + */ 1061 + export const zCamelCaseCommentWithBreaksWritable = z.int(); 1062 + 1063 + /** 1064 + * Testing multiline comments in string: First line 1065 + * Second line 1066 + * 1067 + * Fourth line 1068 + */ 1069 + export const zCommentWithBreaksWritable = z.int(); 1070 + 1071 + /** 1072 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 1073 + */ 1074 + export const zCommentWithBackticksWritable = z.int(); 1075 + 1076 + /** 1077 + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 1078 + */ 1079 + export const zCommentWithBackticksAndQuotesWritable = z.int(); 1080 + 1081 + /** 1082 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 1083 + */ 1084 + export const zCommentWithSlashesWritable = z.int(); 1085 + 1086 + /** 1087 + * Testing expression placeholders in string: ${expression} should work 1088 + */ 1089 + export const zCommentWithExpressionPlaceholdersWritable = z.int(); 1090 + 1091 + /** 1092 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 1093 + */ 1094 + export const zCommentWithQuotesWritable = z.int(); 1095 + 1096 + /** 1097 + * Testing reserved characters in string: * inline * and ** inline ** should work 1098 + */ 1099 + export const zCommentWithReservedCharactersWritable = z.int(); 1100 + 1101 + /** 1102 + * This is a simple number 1103 + */ 1104 + export const zSimpleIntegerWritable = z.int(); 1105 + 1106 + /** 1107 + * This is a simple boolean 1108 + */ 1109 + export const zSimpleBooleanWritable = z.boolean(); 1110 + 1111 + /** 1112 + * This is a simple string 1113 + */ 1114 + export const zSimpleStringWritable = z.string(); 1115 + 1116 + /** 1117 + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 1118 + */ 1119 + export const zNonAsciiStringæøåÆøÅöôêÊ字符串Writable = z.string(); 1120 + 1121 + /** 1122 + * This is a simple file 1123 + */ 1124 + export const zSimpleFileWritable = z.string(); 1125 + 1126 + /** 1127 + * This is a simple string 1128 + */ 1129 + export const zSimpleStringWithPatternWritable = z.union([ 1130 + z.string().check(z.maxLength(64), z.regex(/^[a-zA-Z0-9_]*$/)), 1131 + z.null() 1132 + ]); 1133 + 1134 + /** 1135 + * This is a simple enum with strings 1136 + */ 1137 + export const zEnumWithStringsWritable = z.enum([ 1138 + 'Success', 1139 + 'Warning', 1140 + 'Error', 1141 + "'Single Quote'", 1142 + '"Double Quotes"', 1143 + 'Non-ascii: øæåôöØÆÅÔÖ字符串' 1144 + ]); 1145 + 1146 + export const zEnumWithReplacedCharactersWritable = z.enum([ 1147 + "'Single Quote'", 1148 + '"Double Quotes"', 1149 + 'øæåôöØÆÅÔÖ字符串', 1150 + '' 1151 + ]); 1152 + 1153 + /** 1154 + * This is a simple enum with numbers 1155 + */ 1156 + export const zEnumWithNumbersWritable = z.unknown(); 1157 + 1158 + /** 1159 + * Success=1,Warning=2,Error=3 1160 + */ 1161 + export const zEnumFromDescriptionWritable = z.number(); 1162 + 1163 + /** 1164 + * This is a simple enum with numbers 1165 + */ 1166 + export const zEnumWithExtensionsWritable = z.unknown(); 1167 + 1168 + export const zEnumWithXEnumNamesWritable = z.unknown(); 1169 + 1170 + /** 1171 + * This is a simple array with numbers 1172 + */ 1173 + export const zArrayWithNumbersWritable = z.array(z.int()); 1174 + 1175 + /** 1176 + * This is a simple array with booleans 1177 + */ 1178 + export const zArrayWithBooleansWritable = z.array(z.boolean()); 1179 + 1180 + /** 1181 + * This is a simple array with strings 1182 + */ 1183 + export const zArrayWithStringsWritable = z._default(z.array(z.string()), ['test']); 1184 + 1185 + /** 1186 + * This is a string dictionary 1187 + */ 1188 + export const zDictionaryWithStringWritable = z.object({}); 1189 + 1190 + /** 1191 + * This is a string dictionary 1192 + */ 1193 + export const zDictionaryWithDictionaryWritable = z.record(z.string(), z.object({})); 1194 + 1195 + /** 1196 + * `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) 1197 + */ 1198 + export const zModelFromZendeskWritable = z.string(); 1199 + 1200 + export const zModelWithReadOnlyAndWriteOnlyWritable = z.object({ 1201 + foo: z.string(), 1202 + baz: z.string() 1203 + }); 1204 + 1205 + /** 1206 + * This is a model with one property containing an array 1207 + */ 1208 + export const zModelWithArrayReadOnlyAndWriteOnlyWritable = z.object({ 1209 + prop: z.optional(z.array(zModelWithReadOnlyAndWriteOnlyWritable)), 1210 + propWithFile: z.optional(z.array(z.string())), 1211 + propWithNumber: z.optional(z.array(z.number())) 1212 + }); 1213 + 1214 + export const z3eNum1ПериодWritable = z.enum([ 1215 + 'Bird', 1216 + 'Dog' 1217 + ]); 1218 + 1219 + export const zConstValueWritable = z.enum([ 1220 + 'ConstValue' 1221 + ]); 1222 + 1223 + /** 1224 + * This is a free-form object without additionalProperties. 1225 + */ 1226 + export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.object({}); 1227 + 1228 + /** 1229 + * This is a free-form object with additionalProperties: true. 1230 + */ 1231 + export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.object({}); 1232 + 1233 + /** 1234 + * This is a free-form object with additionalProperties: {}. 1235 + */ 1236 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.object({}); 1237 + 1238 + /** 1239 + * Some % character 1240 + */ 1241 + export const zCharactersInDescriptionWritable = z.string(); 1242 + 1243 + export const zModelWithNestedArrayEnumsDataFooWritable = z.enum([ 1244 + 'foo', 1245 + 'bar' 1246 + ]); 1247 + 1248 + export const zModelWithNestedArrayEnumsDataBarWritable = z.enum([ 1249 + 'baz', 1250 + 'qux' 1251 + ]); 1252 + 1253 + export const zModelWithConstantSizeArrayWritable = z.tuple([ 1254 + z.number(), 1255 + z.number() 1256 + ]); 1257 + 1258 + export const zModelWithAnyOfConstantSizeArrayWritable = z.tuple([ 1259 + z.union([ 1260 + z.number(), 1261 + z.string() 1262 + ]), 1263 + z.union([ 1264 + z.number(), 1265 + z.string() 1266 + ]), 1267 + z.union([ 1268 + z.number(), 1269 + z.string() 1270 + ]) 1271 + ]); 1272 + 1273 + export const zModelWithAnyOfConstantSizeArrayNullableWritable = z.tuple([ 1274 + z.union([ 1275 + z.number(), 1276 + z.null(), 1277 + z.string() 1278 + ]), 1279 + z.union([ 1280 + z.number(), 1281 + z.null(), 1282 + z.string() 1283 + ]), 1284 + z.union([ 1285 + z.number(), 1286 + z.null(), 1287 + z.string() 1288 + ]) 1289 + ]); 1290 + 1291 + /** 1292 + * Model with restricted keyword name 1293 + */ 1294 + export const zImportWritable = z.string(); 1295 + 1296 + export const zModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = z.tuple([ 1297 + z.union([ 1298 + z.number(), 1299 + zImportWritable 1300 + ]), 1301 + z.union([ 1302 + z.number(), 1303 + zImportWritable 1304 + ]) 1305 + ]); 1306 + 1307 + export const zModelWithAnyOfConstantSizeArrayAndIntersectWritable = z.tuple([ 1308 + z.intersection(z.number(), z.string()), 1309 + z.intersection(z.number(), z.string()) 1310 + ]); 1311 + 1312 + /** 1313 + * Model used to test deduplication strategy (unused) 1314 + */ 1315 + export const zParameterSimpleParameterUnusedWritable = z.string(); 1316 + 1317 + /** 1318 + * Model used to test deduplication strategy 1319 + */ 1320 + export const zPostServiceWithEmptyTagResponseWritable = z.string(); 1321 + 1322 + /** 1323 + * Model used to test deduplication strategy 1324 + */ 1325 + export const zPostServiceWithEmptyTagResponse2Writable = z.string(); 1326 + 1327 + /** 1328 + * Model used to test deduplication strategy 1329 + */ 1330 + export const zDeleteFooDataWritable = z.string(); 1331 + 1332 + /** 1333 + * Model used to test deduplication strategy 1334 + */ 1335 + export const zDeleteFooData2Writable = z.string(); 1336 + 1337 + export const zAdditionalPropertiesUnknownIssueWritable = z.object({}); 1338 + 1339 + export const zAdditionalPropertiesUnknownIssue2Writable = z.object({}); 1340 + 1341 + export const zOneOfAllOfIssueWritable = z.union([ 1342 + z.intersection(z.union([ 1343 + zConstValueWritable, 1344 + zGenericSchemaDuplicateIssue1SystemBoolean 1345 + ]), z3eNum1Период), 1346 + zGenericSchemaDuplicateIssue1SystemString 1347 + ]); 1348 + 1349 + /** 1350 + * Parameter with illegal characters 1351 + */ 1352 + export const zXFooBar = zModelWithString; 1353 + 1354 + export const zSimpleRequestBody = zModelWithString; 1355 + 1356 + export const zSimpleFormData = zModelWithString; 1357 + 1358 + export const zExportData = z.object({ 1359 + body: z.optional(z.never()), 1360 + path: z.optional(z.never()), 1361 + query: z.optional(z.never()) 1362 + }); 1363 + 1364 + export const zPatchApiVbyApiVersionNoTagData = z.object({ 1365 + body: z.optional(z.never()), 1366 + path: z.optional(z.never()), 1367 + query: z.optional(z.never()) 1368 + }); 1369 + 1370 + export const zImportData = z.object({ 1371 + body: z.union([ 1372 + zModelWithReadOnlyAndWriteOnlyWritable, 1373 + zModelWithArrayReadOnlyAndWriteOnlyWritable 1374 + ]), 1375 + path: z.optional(z.never()), 1376 + query: z.optional(z.never()) 1377 + }); 1378 + 1379 + export const zImportResponse = z.union([ 1380 + zModelFromZendesk, 1381 + zModelWithReadOnlyAndWriteOnly 1382 + ]); 1383 + 1384 + export const zFooWowData = z.object({ 1385 + body: z.optional(z.never()), 1386 + path: z.optional(z.never()), 1387 + query: z.optional(z.never()) 1388 + }); 1389 + 1390 + export const zApiVVersionODataControllerCountData = z.object({ 1391 + body: z.optional(z.never()), 1392 + path: z.optional(z.never()), 1393 + query: z.optional(z.never()) 1394 + }); 1395 + 1396 + /** 1397 + * Success 1398 + */ 1399 + export const zApiVVersionODataControllerCountResponse = zModelFromZendesk; 1400 + 1401 + export const zGetApiVbyApiVersionSimpleOperationData = z.object({ 1402 + body: z.optional(z.never()), 1403 + path: z.object({ 1404 + foo_param: z.string() 1405 + }), 1406 + query: z.optional(z.never()) 1407 + }); 1408 + 1409 + /** 1410 + * Response is a simple number 1411 + */ 1412 + export const zGetApiVbyApiVersionSimpleOperationResponse = z.number(); 1413 + 1414 + export const zDeleteCallWithoutParametersAndResponseData = z.object({ 1415 + body: z.optional(z.never()), 1416 + path: z.optional(z.never()), 1417 + query: z.optional(z.never()) 1418 + }); 1419 + 1420 + export const zGetCallWithoutParametersAndResponseData = z.object({ 1421 + body: z.optional(z.never()), 1422 + path: z.optional(z.never()), 1423 + query: z.optional(z.never()) 1424 + }); 1425 + 1426 + export const zHeadCallWithoutParametersAndResponseData = z.object({ 1427 + body: z.optional(z.never()), 1428 + path: z.optional(z.never()), 1429 + query: z.optional(z.never()) 1430 + }); 1431 + 1432 + export const zOptionsCallWithoutParametersAndResponseData = z.object({ 1433 + body: z.optional(z.never()), 1434 + path: z.optional(z.never()), 1435 + query: z.optional(z.never()) 1436 + }); 1437 + 1438 + export const zPatchCallWithoutParametersAndResponseData = z.object({ 1439 + body: z.optional(z.never()), 1440 + path: z.optional(z.never()), 1441 + query: z.optional(z.never()) 1442 + }); 1443 + 1444 + export const zPostCallWithoutParametersAndResponseData = z.object({ 1445 + body: z.optional(z.never()), 1446 + path: z.optional(z.never()), 1447 + query: z.optional(z.never()) 1448 + }); 1449 + 1450 + export const zPutCallWithoutParametersAndResponseData = z.object({ 1451 + body: z.optional(z.never()), 1452 + path: z.optional(z.never()), 1453 + query: z.optional(z.never()) 1454 + }); 1455 + 1456 + export const zDeleteFooData3 = z.object({ 1457 + body: z.optional(z.never()), 1458 + path: z.object({ 1459 + foo_param: z.string(), 1460 + BarParam: z.string() 1461 + }), 1462 + query: z.optional(z.never()), 1463 + headers: z.object({ 1464 + 'x-Foo-Bar': zModelWithString 1465 + }) 1466 + }); 1467 + 1468 + export const zCallWithDescriptionsData = z.object({ 1469 + body: z.optional(z.never()), 1470 + path: z.optional(z.never()), 1471 + query: z.optional(z.object({ 1472 + parameterWithBreaks: z.optional(z.string()), 1473 + parameterWithBackticks: z.optional(z.string()), 1474 + parameterWithSlashes: z.optional(z.string()), 1475 + parameterWithExpressionPlaceholders: z.optional(z.string()), 1476 + parameterWithQuotes: z.optional(z.string()), 1477 + parameterWithReservedCharacters: z.optional(z.string()) 1478 + })) 1479 + }); 1480 + 1481 + export const zDeprecatedCallData = z.object({ 1482 + body: z.optional(z.never()), 1483 + path: z.optional(z.never()), 1484 + query: z.optional(z.never()), 1485 + headers: z.object({ 1486 + parameter: z.union([ 1487 + zDeprecatedModel, 1488 + z.null() 1489 + ]) 1490 + }) 1491 + }); 1492 + 1493 + export const zCallWithParametersData = z.object({ 1494 + body: z.union([ 1495 + z.object({}), 1496 + z.null() 1497 + ]), 1498 + path: z.object({ 1499 + parameterPath: z.union([ 1500 + z.string(), 1501 + z.null() 1502 + ]), 1503 + 'api-version': z.union([ 1504 + z.string(), 1505 + z.null() 1506 + ]) 1507 + }), 1508 + query: z.object({ 1509 + foo_ref_enum: z.optional(zModelWithNestedArrayEnumsDataFooWritable), 1510 + foo_all_of_enum: zModelWithNestedArrayEnumsDataFooWritable, 1511 + cursor: z.union([ 1512 + z.string(), 1513 + z.null() 1514 + ]) 1515 + }), 1516 + headers: z.object({ 1517 + parameterHeader: z.union([ 1518 + z.string(), 1519 + z.null() 1520 + ]) 1521 + }) 1522 + }); 1523 + 1524 + export const zCallWithWeirdParameterNamesData = z.object({ 1525 + body: z.union([ 1526 + zModelWithString, 1527 + z.null() 1528 + ]), 1529 + path: z.object({ 1530 + 'parameter.path.1': z.optional(z.string()), 1531 + 'parameter-path-2': z.optional(z.string()), 1532 + 'PARAMETER-PATH-3': z.optional(z.string()), 1533 + 'api-version': z.union([ 1534 + z.string(), 1535 + z.null() 1536 + ]) 1537 + }), 1538 + query: z.object({ 1539 + default: z.optional(z.string()), 1540 + 'parameter-query': z.union([ 1541 + z.string(), 1542 + z.null() 1543 + ]) 1544 + }), 1545 + headers: z.object({ 1546 + 'parameter.header': z.union([ 1547 + z.string(), 1548 + z.null() 1549 + ]) 1550 + }) 1551 + }); 1552 + 1553 + export const zGetCallWithOptionalParamData = z.object({ 1554 + body: zModelWithOneOfEnum, 1555 + path: z.optional(z.never()), 1556 + query: z.optional(z.object({ 1557 + page: z.optional(z.number()) 1558 + })) 1559 + }); 1560 + 1561 + export const zPostCallWithOptionalParamData = z.object({ 1562 + body: z.optional(z.object({ 1563 + offset: z.optional(z.union([ 1564 + z.number(), 1565 + z.null() 1566 + ])) 1567 + })), 1568 + path: z.optional(z.never()), 1569 + query: z.object({ 1570 + parameter: zPageable 1571 + }) 1572 + }); 1573 + 1574 + export const zPostCallWithOptionalParamResponse = z.union([ 1575 + z.number(), 1576 + z.void() 1577 + ]); 1578 + 1579 + export const zPostApiVbyApiVersionRequestBodyData = z.object({ 1580 + body: z.optional(zSimpleRequestBody), 1581 + path: z.optional(z.never()), 1582 + query: z.optional(z.object({ 1583 + parameter: z.optional(z.string()) 1584 + })) 1585 + }); 1586 + 1587 + export const zPostApiVbyApiVersionFormDataData = z.object({ 1588 + body: z.optional(zSimpleFormData), 1589 + path: z.optional(z.never()), 1590 + query: z.optional(z.object({ 1591 + parameter: z.optional(z.string()) 1592 + })) 1593 + }); 1594 + 1595 + export const zCallWithDefaultParametersData = z.object({ 1596 + body: z.optional(z.never()), 1597 + path: z.optional(z.never()), 1598 + query: z.optional(z.object({ 1599 + parameterString: z._default(z.optional(z.union([ 1600 + z._default(z.string(), 'Hello World!'), 1601 + z.null() 1602 + ])), 'Hello World!'), 1603 + parameterNumber: z._default(z.optional(z.union([ 1604 + z._default(z.number(), 123), 1605 + z.null() 1606 + ])), 123), 1607 + parameterBoolean: z._default(z.optional(z.union([ 1608 + z._default(z.boolean(), true), 1609 + z.null() 1610 + ])), true), 1611 + parameterEnum: z.optional(z.enum([ 1612 + 'Success', 1613 + 'Warning', 1614 + 'Error' 1615 + ])), 1616 + parameterModel: z.optional(z.union([ 1617 + zModelWithString, 1618 + z.null() 1619 + ])) 1620 + })) 1621 + }); 1622 + 1623 + export const zCallWithDefaultOptionalParametersData = z.object({ 1624 + body: z.optional(z.never()), 1625 + path: z.optional(z.never()), 1626 + query: z.optional(z.object({ 1627 + parameterString: z._default(z.optional(z.string()), 'Hello World!'), 1628 + parameterNumber: z._default(z.optional(z.number()), 123), 1629 + parameterBoolean: z._default(z.optional(z.boolean()), true), 1630 + parameterEnum: z.optional(z.enum([ 1631 + 'Success', 1632 + 'Warning', 1633 + 'Error' 1634 + ])), 1635 + parameterModel: z.optional(zModelWithString) 1636 + })) 1637 + }); 1638 + 1639 + export const zCallToTestOrderOfParamsData = z.object({ 1640 + body: z.optional(z.never()), 1641 + path: z.optional(z.never()), 1642 + query: z.object({ 1643 + parameterOptionalStringWithDefault: z._default(z.optional(z.string()), 'Hello World!'), 1644 + parameterOptionalStringWithEmptyDefault: z._default(z.optional(z.string()), ''), 1645 + parameterOptionalStringWithNoDefault: z.optional(z.string()), 1646 + parameterStringWithDefault: z._default(z.string(), 'Hello World!'), 1647 + parameterStringWithEmptyDefault: z._default(z.string(), ''), 1648 + parameterStringWithNoDefault: z.string(), 1649 + parameterStringNullableWithNoDefault: z.optional(z.union([ 1650 + z.string(), 1651 + z.null() 1652 + ])), 1653 + parameterStringNullableWithDefault: z._default(z.optional(z.union([ 1654 + z.string(), 1655 + z.null() 1656 + ])), null) 1657 + }) 1658 + }); 1659 + 1660 + export const zDuplicateNameData = z.object({ 1661 + body: z.optional(z.never()), 1662 + path: z.optional(z.never()), 1663 + query: z.optional(z.never()) 1664 + }); 1665 + 1666 + export const zDuplicateName2Data = z.object({ 1667 + body: z.optional(z.never()), 1668 + path: z.optional(z.never()), 1669 + query: z.optional(z.never()) 1670 + }); 1671 + 1672 + export const zDuplicateName3Data = z.object({ 1673 + body: z.optional(z.never()), 1674 + path: z.optional(z.never()), 1675 + query: z.optional(z.never()) 1676 + }); 1677 + 1678 + export const zDuplicateName4Data = z.object({ 1679 + body: z.optional(z.never()), 1680 + path: z.optional(z.never()), 1681 + query: z.optional(z.never()) 1682 + }); 1683 + 1684 + export const zCallWithNoContentResponseData = z.object({ 1685 + body: z.optional(z.never()), 1686 + path: z.optional(z.never()), 1687 + query: z.optional(z.never()) 1688 + }); 1689 + 1690 + /** 1691 + * Success 1692 + */ 1693 + export const zCallWithNoContentResponseResponse = z.void(); 1694 + 1695 + export const zCallWithResponseAndNoContentResponseData = z.object({ 1696 + body: z.optional(z.never()), 1697 + path: z.optional(z.never()), 1698 + query: z.optional(z.never()) 1699 + }); 1700 + 1701 + export const zCallWithResponseAndNoContentResponseResponse = z.union([ 1702 + z.number(), 1703 + z.void() 1704 + ]); 1705 + 1706 + export const zDummyAData = z.object({ 1707 + body: z.optional(z.never()), 1708 + path: z.optional(z.never()), 1709 + query: z.optional(z.never()) 1710 + }); 1711 + 1712 + export const zDummyAResponse = z400; 1713 + 1714 + export const zDummyBData = z.object({ 1715 + body: z.optional(z.never()), 1716 + path: z.optional(z.never()), 1717 + query: z.optional(z.never()) 1718 + }); 1719 + 1720 + /** 1721 + * Success 1722 + */ 1723 + export const zDummyBResponse = z.void(); 1724 + 1725 + export const zCallWithResponseData = z.object({ 1726 + body: z.optional(z.never()), 1727 + path: z.optional(z.never()), 1728 + query: z.optional(z.never()) 1729 + }); 1730 + 1731 + export const zCallWithResponseResponse = zImport; 1732 + 1733 + export const zCallWithDuplicateResponsesData = z.object({ 1734 + body: z.optional(z.never()), 1735 + path: z.optional(z.never()), 1736 + query: z.optional(z.never()) 1737 + }); 1738 + 1739 + export const zCallWithDuplicateResponsesResponse = z.union([ 1740 + z.intersection(zModelWithBoolean, zModelWithInteger), 1741 + zModelWithString 1742 + ]); 1743 + 1744 + export const zCallWithResponsesData = z.object({ 1745 + body: z.optional(z.never()), 1746 + path: z.optional(z.never()), 1747 + query: z.optional(z.never()) 1748 + }); 1749 + 1750 + export const zCallWithResponsesResponse = z.union([ 1751 + z.object({ 1752 + '@namespace.string': z.optional(z.readonly(z.string())), 1753 + '@namespace.integer': z.optional(z.readonly(z.int())), 1754 + value: z.optional(z.readonly(z.array(zModelWithString))) 1755 + }), 1756 + zModelThatExtends, 1757 + zModelThatExtendsExtends 1758 + ]); 1759 + 1760 + export const zCollectionFormatData = z.object({ 1761 + body: z.optional(z.never()), 1762 + path: z.optional(z.never()), 1763 + query: z.object({ 1764 + parameterArrayCSV: z.union([ 1765 + z.array(z.string()), 1766 + z.null() 1767 + ]), 1768 + parameterArraySSV: z.union([ 1769 + z.array(z.string()), 1770 + z.null() 1771 + ]), 1772 + parameterArrayTSV: z.union([ 1773 + z.array(z.string()), 1774 + z.null() 1775 + ]), 1776 + parameterArrayPipes: z.union([ 1777 + z.array(z.string()), 1778 + z.null() 1779 + ]), 1780 + parameterArrayMulti: z.union([ 1781 + z.array(z.string()), 1782 + z.null() 1783 + ]) 1784 + }) 1785 + }); 1786 + 1787 + export const zTypesData = z.object({ 1788 + body: z.optional(z.never()), 1789 + path: z.optional(z.object({ 1790 + id: z.optional(z.int()) 1791 + })), 1792 + query: z.object({ 1793 + parameterNumber: z._default(z.number(), 123), 1794 + parameterString: z._default(z.union([ 1795 + z._default(z.string(), 'default'), 1796 + z.null() 1797 + ]), 'default'), 1798 + parameterBoolean: z._default(z.union([ 1799 + z._default(z.boolean(), true), 1800 + z.null() 1801 + ]), true), 1802 + parameterObject: z._default(z.union([ 1803 + z.object({}), 1804 + z.null() 1805 + ]), null), 1806 + parameterArray: z.union([ 1807 + z.array(z.string()), 1808 + z.null() 1809 + ]), 1810 + parameterDictionary: z.union([ 1811 + z.object({}), 1812 + z.null() 1813 + ]), 1814 + parameterEnum: z.enum([ 1815 + 'Success', 1816 + 'Warning', 1817 + 'Error' 1818 + ]) 1819 + }) 1820 + }); 1821 + 1822 + export const zTypesResponse = z.union([ 1823 + z.number(), 1824 + z.string(), 1825 + z.boolean(), 1826 + z.object({}) 1827 + ]); 1828 + 1829 + export const zUploadFileData = z.object({ 1830 + body: z.string(), 1831 + path: z.object({ 1832 + 'api-version': z.union([ 1833 + z.string(), 1834 + z.null() 1835 + ]) 1836 + }), 1837 + query: z.optional(z.never()) 1838 + }); 1839 + 1840 + export const zUploadFileResponse = z.boolean(); 1841 + 1842 + export const zFileResponseData = z.object({ 1843 + body: z.optional(z.never()), 1844 + path: z.object({ 1845 + id: z.string(), 1846 + 'api-version': z.string() 1847 + }), 1848 + query: z.optional(z.never()) 1849 + }); 1850 + 1851 + /** 1852 + * Success 1853 + */ 1854 + export const zFileResponseResponse = z.string(); 1855 + 1856 + export const zComplexTypesData = z.object({ 1857 + body: z.optional(z.never()), 1858 + path: z.optional(z.never()), 1859 + query: z.object({ 1860 + parameterObject: z.object({ 1861 + first: z.optional(z.object({ 1862 + second: z.optional(z.object({ 1863 + third: z.optional(z.string()) 1864 + })) 1865 + })) 1866 + }), 1867 + parameterReference: zModelWithString 1868 + }) 1869 + }); 1870 + 1871 + /** 1872 + * Successful response 1873 + */ 1874 + export const zComplexTypesResponse = z.array(zModelWithString); 1875 + 1876 + export const zMultipartResponseData = z.object({ 1877 + body: z.optional(z.never()), 1878 + path: z.optional(z.never()), 1879 + query: z.optional(z.never()) 1880 + }); 1881 + 1882 + /** 1883 + * OK 1884 + */ 1885 + export const zMultipartResponseResponse = z.object({ 1886 + file: z.optional(z.string()), 1887 + metadata: z.optional(z.object({ 1888 + foo: z.optional(z.string()), 1889 + bar: z.optional(z.string()) 1890 + })) 1891 + }); 1892 + 1893 + export const zMultipartRequestData = z.object({ 1894 + body: z.optional(z.object({ 1895 + content: z.optional(z.string()), 1896 + data: z.optional(z.union([ 1897 + zModelWithString, 1898 + z.null() 1899 + ])) 1900 + })), 1901 + path: z.optional(z.never()), 1902 + query: z.optional(z.never()) 1903 + }); 1904 + 1905 + export const zComplexParamsData = z.object({ 1906 + body: z.optional(z.object({ 1907 + key: z.readonly(z.union([ 1908 + z.readonly(z.string().check(z.maxLength(64), z.regex(/^[a-zA-Z0-9_]*$/))), 1909 + z.null() 1910 + ])), 1911 + name: z.union([ 1912 + z.string().check(z.maxLength(255)), 1913 + z.null() 1914 + ]), 1915 + enabled: z._default(z.optional(z.boolean()), true), 1916 + type: z.enum([ 1917 + 'Monkey', 1918 + 'Horse', 1919 + 'Bird' 1920 + ]), 1921 + listOfModels: z.optional(z.union([ 1922 + z.array(zModelWithString), 1923 + z.null() 1924 + ])), 1925 + listOfStrings: z.optional(z.union([ 1926 + z.array(z.string()), 1927 + z.null() 1928 + ])), 1929 + parameters: z.union([ 1930 + zModelWithString, 1931 + zModelWithEnum, 1932 + zModelWithArray, 1933 + zModelWithDictionary 1934 + ]), 1935 + user: z.optional(z.readonly(z.object({ 1936 + id: z.optional(z.readonly(z.int())), 1937 + name: z.optional(z.readonly(z.union([ 1938 + z.readonly(z.string()), 1939 + z.null() 1940 + ]))) 1941 + }))) 1942 + })), 1943 + path: z.object({ 1944 + id: z.int(), 1945 + 'api-version': z.string() 1946 + }), 1947 + query: z.optional(z.never()) 1948 + }); 1949 + 1950 + /** 1951 + * Success 1952 + */ 1953 + export const zComplexParamsResponse = zModelWithString; 1954 + 1955 + export const zCallWithResultFromHeaderData = z.object({ 1956 + body: z.optional(z.never()), 1957 + path: z.optional(z.never()), 1958 + query: z.optional(z.never()) 1959 + }); 1960 + 1961 + export const zTestErrorCodeData = z.object({ 1962 + body: z.optional(z.never()), 1963 + path: z.optional(z.never()), 1964 + query: z.object({ 1965 + status: z.int() 1966 + }) 1967 + }); 1968 + 1969 + export const zNonAsciiæøåÆøÅöôêÊ字符串Data = z.object({ 1970 + body: z.optional(z.never()), 1971 + path: z.optional(z.never()), 1972 + query: z.object({ 1973 + 'nonAsciiParamæøåÆØÅöôêÊ': z.int() 1974 + }) 1975 + }); 1976 + 1977 + /** 1978 + * Successful response 1979 + */ 1980 + export const zNonAsciiæøåÆøÅöôêÊ字符串Response = z.array(zNonAsciiStringæøåÆøÅöôêÊ字符串); 1981 + 1982 + export const zPutWithFormUrlEncodedData = z.object({ 1983 + body: zArrayWithStringsWritable, 1984 + path: z.optional(z.never()), 1985 + query: z.optional(z.never()) 1986 + });
+18
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/enum-null/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as z from 'zod/mini'; 4 + 5 + export const zFoo = z.nullable(z.enum([ 6 + 'foo', 7 + 'bar' 8 + ])); 9 + 10 + export const zBar = z.enum([ 11 + 'foo', 12 + 'bar' 13 + ]); 14 + 15 + export const zBaz = z.enum([ 16 + 'foo', 17 + 'bar' 18 + ]);
+24
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/type-format-zod/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as z from 'zod/mini'; 4 + 5 + export const zFoo = z.object({ 6 + bar: z.optional(z.int()), 7 + foo: z._default(z.coerce.bigint(), BigInt(0)), 8 + id: z.string() 9 + }); 10 + 11 + export const zBar = z.object({ 12 + foo: z.int() 13 + }); 14 + 15 + export const zPostFooData = z.object({ 16 + body: z.optional(z.never()), 17 + path: z.optional(z.never()), 18 + query: z.optional(z.never()) 19 + }); 20 + 21 + /** 22 + * OK 23 + */ 24 + export const zPostFooResponse = zFoo;
+25
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/mini/validators/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as z from 'zod/mini'; 4 + 5 + export const zBar = z.object({ 6 + get foo(): z.ZodMiniOptional { 7 + return z.optional(zFoo); 8 + } 9 + }); 10 + 11 + export const zFoo = z._default(z.union([ 12 + z.object({ 13 + foo: z.optional(z.string().check(z.regex(/^\d{3}-\d{2}-\d{4}$/))), 14 + bar: z.optional(zBar), 15 + get baz(): z.ZodMiniOptional { 16 + return z.optional(z.array(z.lazy((): any => { 17 + return zFoo; 18 + }))); 19 + }, 20 + qux: z._default(z.optional(z.int().check(z.gt(0))), 0) 21 + }), 22 + z.null() 23 + ]), null); 24 + 25 + export const zBaz = z._default(z.readonly(z.string().check(z.regex(/foo\nbar/))), 'baz');
+9
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/array-items-one-of-length-1/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod/v3'; 4 + 5 + export const zBar = z.string(); 6 + 7 + export const zFoo = z.object({ 8 + foo: z.array(zBar).min(1).max(2147483647).optional() 9 + });
+1984
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/default/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod/v3'; 4 + 5 + /** 6 + * Model with number-only name 7 + */ 8 + export const z400 = z.string(); 9 + 10 + /** 11 + * Testing multiline comments in string: First line 12 + * Second line 13 + * 14 + * Fourth line 15 + */ 16 + export const zCamelCaseCommentWithBreaks = z.number().int(); 17 + 18 + /** 19 + * Testing multiline comments in string: First line 20 + * Second line 21 + * 22 + * Fourth line 23 + */ 24 + export const zCommentWithBreaks = z.number().int(); 25 + 26 + /** 27 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 28 + */ 29 + export const zCommentWithBackticks = z.number().int(); 30 + 31 + /** 32 + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 33 + */ 34 + export const zCommentWithBackticksAndQuotes = z.number().int(); 35 + 36 + /** 37 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 38 + */ 39 + export const zCommentWithSlashes = z.number().int(); 40 + 41 + /** 42 + * Testing expression placeholders in string: ${expression} should work 43 + */ 44 + export const zCommentWithExpressionPlaceholders = z.number().int(); 45 + 46 + /** 47 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 48 + */ 49 + export const zCommentWithQuotes = z.number().int(); 50 + 51 + /** 52 + * Testing reserved characters in string: * inline * and ** inline ** should work 53 + */ 54 + export const zCommentWithReservedCharacters = z.number().int(); 55 + 56 + /** 57 + * This is a simple number 58 + */ 59 + export const zSimpleInteger = z.number().int(); 60 + 61 + /** 62 + * This is a simple boolean 63 + */ 64 + export const zSimpleBoolean = z.boolean(); 65 + 66 + /** 67 + * This is a simple string 68 + */ 69 + export const zSimpleString = z.string(); 70 + 71 + /** 72 + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 73 + */ 74 + export const zNonAsciiStringæøåÆøÅöôêÊ字符串 = z.string(); 75 + 76 + /** 77 + * This is a simple file 78 + */ 79 + export const zSimpleFile = z.string(); 80 + 81 + /** 82 + * This is a model with one string property 83 + */ 84 + export const zModelWithString = z.object({ 85 + prop: z.string().optional() 86 + }); 87 + 88 + /** 89 + * This is a simple reference 90 + */ 91 + export const zSimpleReference = zModelWithString; 92 + 93 + /** 94 + * This is a simple string 95 + */ 96 + export const zSimpleStringWithPattern = z.union([ 97 + z.string().max(64).regex(/^[a-zA-Z0-9_]*$/), 98 + z.null() 99 + ]); 100 + 101 + /** 102 + * This is a simple enum with strings 103 + */ 104 + export const zEnumWithStrings = z.enum([ 105 + 'Success', 106 + 'Warning', 107 + 'Error', 108 + "'Single Quote'", 109 + '"Double Quotes"', 110 + 'Non-ascii: øæåôöØÆÅÔÖ字符串' 111 + ]); 112 + 113 + export const zEnumWithReplacedCharacters = z.enum([ 114 + "'Single Quote'", 115 + '"Double Quotes"', 116 + 'øæåôöØÆÅÔÖ字符串', 117 + '' 118 + ]); 119 + 120 + /** 121 + * This is a simple enum with numbers 122 + */ 123 + export const zEnumWithNumbers = z.unknown(); 124 + 125 + /** 126 + * Success=1,Warning=2,Error=3 127 + */ 128 + export const zEnumFromDescription = z.number(); 129 + 130 + /** 131 + * This is a simple enum with numbers 132 + */ 133 + export const zEnumWithExtensions = z.unknown(); 134 + 135 + export const zEnumWithXEnumNames = z.unknown(); 136 + 137 + /** 138 + * This is a simple array with numbers 139 + */ 140 + export const zArrayWithNumbers = z.array(z.number().int()); 141 + 142 + /** 143 + * This is a simple array with booleans 144 + */ 145 + export const zArrayWithBooleans = z.array(z.boolean()); 146 + 147 + /** 148 + * This is a simple array with strings 149 + */ 150 + export const zArrayWithStrings = z.array(z.string()).default(['test']); 151 + 152 + /** 153 + * This is a simple array with references 154 + */ 155 + export const zArrayWithReferences = z.array(zModelWithString); 156 + 157 + /** 158 + * This is a simple array containing an array 159 + */ 160 + export const zArrayWithArray = z.array(z.array(zModelWithString)); 161 + 162 + /** 163 + * This is a simple array with properties 164 + */ 165 + export const zArrayWithProperties = z.array(z.object({ 166 + '16x16': zCamelCaseCommentWithBreaks.optional(), 167 + bar: z.string().optional() 168 + })); 169 + 170 + /** 171 + * This is a simple array with any of properties 172 + */ 173 + export const zArrayWithAnyOfProperties = z.array(z.union([ 174 + z.object({ 175 + foo: z.string().optional().default('test') 176 + }), 177 + z.object({ 178 + bar: z.string().optional() 179 + }) 180 + ])); 181 + 182 + export const zAnyOfAnyAndNull = z.object({ 183 + data: z.unknown().optional() 184 + }); 185 + 186 + /** 187 + * This is a simple array with any of properties 188 + */ 189 + export const zAnyOfArrays = z.object({ 190 + results: z.array(z.union([ 191 + z.object({ 192 + foo: z.string().optional() 193 + }), 194 + z.object({ 195 + bar: z.string().optional() 196 + }) 197 + ])).optional() 198 + }); 199 + 200 + /** 201 + * This is a string dictionary 202 + */ 203 + export const zDictionaryWithString = z.object({}); 204 + 205 + export const zDictionaryWithPropertiesAndAdditionalProperties = z.object({ 206 + foo: z.number().optional(), 207 + bar: z.boolean().optional() 208 + }); 209 + 210 + /** 211 + * This is a string reference 212 + */ 213 + export const zDictionaryWithReference = z.object({}); 214 + 215 + /** 216 + * This is a complex dictionary 217 + */ 218 + export const zDictionaryWithArray = z.object({}); 219 + 220 + /** 221 + * This is a string dictionary 222 + */ 223 + export const zDictionaryWithDictionary = z.record(z.object({})); 224 + 225 + /** 226 + * This is a complex dictionary 227 + */ 228 + export const zDictionaryWithProperties = z.record(z.object({ 229 + foo: z.string().optional(), 230 + bar: z.string().optional() 231 + })); 232 + 233 + /** 234 + * This is a model with one number property 235 + */ 236 + export const zModelWithInteger = z.object({ 237 + prop: z.number().int().optional() 238 + }); 239 + 240 + /** 241 + * This is a model with one boolean property 242 + */ 243 + export const zModelWithBoolean = z.object({ 244 + prop: z.boolean().optional() 245 + }); 246 + 247 + /** 248 + * This is a model with one string property 249 + */ 250 + export const zModelWithStringError = z.object({ 251 + prop: z.string().optional() 252 + }); 253 + 254 + /** 255 + * `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) 256 + */ 257 + export const zModelFromZendesk = z.string(); 258 + 259 + /** 260 + * This is a model with one string property 261 + */ 262 + export const zModelWithNullableString = z.object({ 263 + nullableProp1: z.union([ 264 + z.string(), 265 + z.null() 266 + ]).optional(), 267 + nullableRequiredProp1: z.union([ 268 + z.string(), 269 + z.null() 270 + ]), 271 + nullableProp2: z.union([ 272 + z.string(), 273 + z.null() 274 + ]).optional(), 275 + nullableRequiredProp2: z.union([ 276 + z.string(), 277 + z.null() 278 + ]), 279 + 'foo_bar-enum': z.enum([ 280 + 'Success', 281 + 'Warning', 282 + 'Error', 283 + 'ØÆÅ字符串' 284 + ]).optional() 285 + }); 286 + 287 + /** 288 + * This is a model with one enum 289 + */ 290 + export const zModelWithEnum = z.object({ 291 + 'foo_bar-enum': z.enum([ 292 + 'Success', 293 + 'Warning', 294 + 'Error', 295 + 'ØÆÅ字符串' 296 + ]).optional(), 297 + statusCode: z.enum([ 298 + '100', 299 + '200 FOO', 300 + '300 FOO_BAR', 301 + '400 foo-bar', 302 + '500 foo.bar', 303 + '600 foo&bar' 304 + ]).optional(), 305 + bool: z.unknown().optional() 306 + }); 307 + 308 + /** 309 + * This is a model with one enum with escaped name 310 + */ 311 + export const zModelWithEnumWithHyphen = z.object({ 312 + 'foo-bar-baz-qux': z.enum([ 313 + '3.0' 314 + ]).optional() 315 + }); 316 + 317 + /** 318 + * This is a model with one enum 319 + */ 320 + export const zModelWithEnumFromDescription = z.object({ 321 + test: z.number().int().optional() 322 + }); 323 + 324 + /** 325 + * This is a model with nested enums 326 + */ 327 + export const zModelWithNestedEnums = z.object({ 328 + dictionaryWithEnum: z.object({}).optional(), 329 + dictionaryWithEnumFromDescription: z.object({}).optional(), 330 + arrayWithEnum: z.array(z.enum([ 331 + 'Success', 332 + 'Warning', 333 + 'Error' 334 + ])).optional(), 335 + arrayWithDescription: z.array(z.number().int()).optional(), 336 + 'foo_bar-enum': z.enum([ 337 + 'Success', 338 + 'Warning', 339 + 'Error', 340 + 'ØÆÅ字符串' 341 + ]).optional() 342 + }); 343 + 344 + /** 345 + * This is a model with one nested property 346 + */ 347 + export const zModelWithProperties = z.object({ 348 + required: z.string(), 349 + requiredAndReadOnly: z.string().readonly(), 350 + requiredAndNullable: z.union([ 351 + z.string(), 352 + z.null() 353 + ]), 354 + string: z.string().optional(), 355 + number: z.number().optional(), 356 + boolean: z.boolean().optional(), 357 + reference: zModelWithString.optional(), 358 + 'property with space': z.string().optional(), 359 + default: z.string().optional(), 360 + try: z.string().optional(), 361 + '@namespace.string': z.string().readonly().optional(), 362 + '@namespace.integer': z.number().int().readonly().optional() 363 + }); 364 + 365 + /** 366 + * This is a model with one property containing a reference 367 + */ 368 + export const zModelWithReference = z.object({ 369 + prop: zModelWithProperties.optional() 370 + }); 371 + 372 + export const zModelWithReadOnlyAndWriteOnly = z.object({ 373 + foo: z.string(), 374 + bar: z.string().readonly() 375 + }); 376 + 377 + /** 378 + * This is a model with one property containing an array 379 + */ 380 + export const zModelWithArrayReadOnlyAndWriteOnly = z.object({ 381 + prop: z.array(zModelWithReadOnlyAndWriteOnly).optional(), 382 + propWithFile: z.array(z.string()).optional(), 383 + propWithNumber: z.array(z.number()).optional() 384 + }); 385 + 386 + /** 387 + * This is a model with one property containing an array 388 + */ 389 + export const zModelWithArray = z.object({ 390 + prop: z.array(zModelWithString).optional(), 391 + propWithFile: z.array(z.string()).optional(), 392 + propWithNumber: z.array(z.number()).optional() 393 + }); 394 + 395 + /** 396 + * This is a model with one property containing a dictionary 397 + */ 398 + export const zModelWithDictionary = z.object({ 399 + prop: z.object({}).optional() 400 + }); 401 + 402 + /** 403 + * This is a deprecated model with a deprecated property 404 + * @deprecated 405 + */ 406 + export const zDeprecatedModel = z.object({ 407 + prop: z.string().optional() 408 + }); 409 + 410 + /** 411 + * This is a model with one property containing a circular reference 412 + */ 413 + export const zModelWithCircularReference: z.AnyZodObject = z.object({ 414 + prop: z.lazy(() => { 415 + return zModelWithCircularReference; 416 + }).optional() 417 + }); 418 + 419 + /** 420 + * This is a model with one property with a 'one of' relationship 421 + */ 422 + export const zCompositionWithOneOf = z.object({ 423 + propA: z.union([ 424 + zModelWithString, 425 + zModelWithEnum, 426 + zModelWithArray, 427 + zModelWithDictionary 428 + ]).optional() 429 + }); 430 + 431 + /** 432 + * This is a model with one property with a 'one of' relationship where the options are not $ref 433 + */ 434 + export const zCompositionWithOneOfAnonymous = z.object({ 435 + propA: z.union([ 436 + z.object({ 437 + propA: z.string().optional() 438 + }), 439 + z.string(), 440 + z.number().int() 441 + ]).optional() 442 + }); 443 + 444 + /** 445 + * Circle 446 + */ 447 + export const zModelCircle = z.object({ 448 + kind: z.string(), 449 + radius: z.number().optional() 450 + }); 451 + 452 + /** 453 + * Square 454 + */ 455 + export const zModelSquare = z.object({ 456 + kind: z.string(), 457 + sideLength: z.number().optional() 458 + }); 459 + 460 + /** 461 + * This is a model with one property with a 'one of' relationship where the options are not $ref 462 + */ 463 + export const zCompositionWithOneOfDiscriminator = z.union([ 464 + z.object({ 465 + kind: z.literal('circle') 466 + }).and(zModelCircle), 467 + z.object({ 468 + kind: z.literal('square') 469 + }).and(zModelSquare) 470 + ]); 471 + 472 + /** 473 + * This is a model with one property with a 'any of' relationship 474 + */ 475 + export const zCompositionWithAnyOf = z.object({ 476 + propA: z.union([ 477 + zModelWithString, 478 + zModelWithEnum, 479 + zModelWithArray, 480 + zModelWithDictionary 481 + ]).optional() 482 + }); 483 + 484 + /** 485 + * This is a model with one property with a 'any of' relationship where the options are not $ref 486 + */ 487 + export const zCompositionWithAnyOfAnonymous = z.object({ 488 + propA: z.union([ 489 + z.object({ 490 + propA: z.string().optional() 491 + }), 492 + z.string(), 493 + z.number().int() 494 + ]).optional() 495 + }); 496 + 497 + /** 498 + * This is a model with nested 'any of' property with a type null 499 + */ 500 + export const zCompositionWithNestedAnyAndTypeNull = z.object({ 501 + propA: z.union([ 502 + z.array(z.union([ 503 + zModelWithDictionary, 504 + z.null() 505 + ])), 506 + z.array(z.union([ 507 + zModelWithArray, 508 + z.null() 509 + ])) 510 + ]).optional() 511 + }); 512 + 513 + export const z3eNum1Период = z.enum([ 514 + 'Bird', 515 + 'Dog' 516 + ]); 517 + 518 + export const zConstValue = z.enum([ 519 + 'ConstValue' 520 + ]); 521 + 522 + /** 523 + * This is a model with one property with a 'any of' relationship where the options are not $ref 524 + */ 525 + export const zCompositionWithNestedAnyOfAndNull = z.object({ 526 + propA: z.union([ 527 + z.array(z.union([ 528 + z3eNum1Период, 529 + zConstValue 530 + ])), 531 + z.null() 532 + ]).optional() 533 + }); 534 + 535 + /** 536 + * This is a model with one property with a 'one of' relationship 537 + */ 538 + export const zCompositionWithOneOfAndNullable = z.object({ 539 + propA: z.union([ 540 + z.object({ 541 + boolean: z.boolean().optional() 542 + }), 543 + zModelWithEnum, 544 + zModelWithArray, 545 + zModelWithDictionary, 546 + z.null() 547 + ]).optional() 548 + }); 549 + 550 + /** 551 + * This is a model that contains a simple dictionary within composition 552 + */ 553 + export const zCompositionWithOneOfAndSimpleDictionary = z.object({ 554 + propA: z.union([ 555 + z.boolean(), 556 + z.object({}) 557 + ]).optional() 558 + }); 559 + 560 + /** 561 + * This is a model that contains a dictionary of simple arrays within composition 562 + */ 563 + export const zCompositionWithOneOfAndSimpleArrayDictionary = z.object({ 564 + propA: z.union([ 565 + z.boolean(), 566 + z.object({}) 567 + ]).optional() 568 + }); 569 + 570 + /** 571 + * This is a model that contains a dictionary of complex arrays (composited) within composition 572 + */ 573 + export const zCompositionWithOneOfAndComplexArrayDictionary = z.object({ 574 + propA: z.union([ 575 + z.boolean(), 576 + z.object({}) 577 + ]).optional() 578 + }); 579 + 580 + /** 581 + * This is a model with one property with a 'all of' relationship 582 + */ 583 + export const zCompositionWithAllOfAndNullable = z.object({ 584 + propA: z.union([ 585 + z.object({ 586 + boolean: z.boolean().optional() 587 + }).and(zModelWithEnum).and(zModelWithArray).and(zModelWithDictionary), 588 + z.null() 589 + ]).optional() 590 + }); 591 + 592 + /** 593 + * This is a model with one property with a 'any of' relationship 594 + */ 595 + export const zCompositionWithAnyOfAndNullable = z.object({ 596 + propA: z.union([ 597 + z.object({ 598 + boolean: z.boolean().optional() 599 + }), 600 + zModelWithEnum, 601 + zModelWithArray, 602 + zModelWithDictionary, 603 + z.null() 604 + ]).optional() 605 + }); 606 + 607 + /** 608 + * This is a base model with two simple optional properties 609 + */ 610 + export const zCompositionBaseModel = z.object({ 611 + firstName: z.string().optional(), 612 + lastname: z.string().optional() 613 + }); 614 + 615 + /** 616 + * This is a model that extends the base model 617 + */ 618 + export const zCompositionExtendedModel = zCompositionBaseModel.and(z.object({ 619 + age: z.number(), 620 + firstName: z.string(), 621 + lastname: z.string() 622 + })); 623 + 624 + /** 625 + * This is a model with one nested property 626 + */ 627 + export const zModelWithNestedProperties = z.object({ 628 + first: z.union([ 629 + z.object({ 630 + second: z.union([ 631 + z.object({ 632 + third: z.union([ 633 + z.string().readonly(), 634 + z.null() 635 + ]).readonly() 636 + }).readonly(), 637 + z.null() 638 + ]).readonly() 639 + }).readonly(), 640 + z.null() 641 + ]).readonly() 642 + }); 643 + 644 + /** 645 + * This is a model with duplicated properties 646 + */ 647 + export const zModelWithDuplicateProperties = z.object({ 648 + prop: zModelWithString.optional() 649 + }); 650 + 651 + /** 652 + * This is a model with ordered properties 653 + */ 654 + export const zModelWithOrderedProperties = z.object({ 655 + zebra: z.string().optional(), 656 + apple: z.string().optional(), 657 + hawaii: z.string().optional() 658 + }); 659 + 660 + /** 661 + * This is a model with duplicated imports 662 + */ 663 + export const zModelWithDuplicateImports = z.object({ 664 + propA: zModelWithString.optional(), 665 + propB: zModelWithString.optional(), 666 + propC: zModelWithString.optional() 667 + }); 668 + 669 + /** 670 + * This is a model that extends another model 671 + */ 672 + export const zModelThatExtends = zModelWithString.and(z.object({ 673 + propExtendsA: z.string().optional(), 674 + propExtendsB: zModelWithString.optional() 675 + })); 676 + 677 + /** 678 + * This is a model that extends another model 679 + */ 680 + export const zModelThatExtendsExtends = zModelWithString.and(zModelThatExtends).and(z.object({ 681 + propExtendsC: z.string().optional(), 682 + propExtendsD: zModelWithString.optional() 683 + })); 684 + 685 + /** 686 + * This is a model that contains a some patterns 687 + */ 688 + export const zModelWithPattern = z.object({ 689 + key: z.string().max(64).regex(/^[a-zA-Z0-9_]*$/), 690 + name: z.string().max(255), 691 + enabled: z.boolean().readonly().optional(), 692 + modified: z.string().datetime().readonly().optional(), 693 + id: z.string().regex(/^\d{2}-\d{3}-\d{4}$/).optional(), 694 + text: z.string().regex(/^\w+$/).optional(), 695 + patternWithSingleQuotes: z.string().regex(/^[a-zA-Z0-9']*$/).optional(), 696 + patternWithNewline: z.string().regex(/aaa\nbbb/).optional(), 697 + patternWithBacktick: z.string().regex(/aaa`bbb/).optional() 698 + }); 699 + 700 + export const zFile = z.object({ 701 + id: z.string().min(1).readonly().optional(), 702 + updated_at: z.string().datetime().readonly().optional(), 703 + created_at: z.string().datetime().readonly().optional(), 704 + mime: z.string().min(1).max(24), 705 + file: z.string().url().readonly().optional() 706 + }); 707 + 708 + export const zDefault = z.object({ 709 + name: z.string().optional() 710 + }); 711 + 712 + export const zPageable = z.object({ 713 + page: z.number().int().gte(0).optional().default(0), 714 + size: z.number().int().gte(1).optional(), 715 + sort: z.array(z.string()).optional() 716 + }); 717 + 718 + /** 719 + * This is a free-form object without additionalProperties. 720 + */ 721 + export const zFreeFormObjectWithoutAdditionalProperties = z.object({}); 722 + 723 + /** 724 + * This is a free-form object with additionalProperties: true. 725 + */ 726 + export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.object({}); 727 + 728 + /** 729 + * This is a free-form object with additionalProperties: {}. 730 + */ 731 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.object({}); 732 + 733 + export const zModelWithConst = z.object({ 734 + String: z.enum([ 735 + 'String' 736 + ]).optional(), 737 + number: z.unknown().optional(), 738 + null: z.unknown().optional(), 739 + withType: z.enum([ 740 + 'Some string' 741 + ]).optional() 742 + }); 743 + 744 + /** 745 + * This is a model with one property and additionalProperties: true 746 + */ 747 + export const zModelWithAdditionalPropertiesEqTrue = z.object({ 748 + prop: z.string().optional() 749 + }); 750 + 751 + export const zNestedAnyOfArraysNullable = z.object({ 752 + nullableArray: z.union([ 753 + z.array(z.union([ 754 + z.string(), 755 + z.boolean() 756 + ])), 757 + z.null() 758 + ]).optional() 759 + }); 760 + 761 + /** 762 + * This is a reusable parameter 763 + */ 764 + export const zSimpleParameter = z.unknown(); 765 + 766 + export const zCompositionWithOneOfAndProperties = z.intersection(z.union([ 767 + z.object({ 768 + foo: zSimpleParameter 769 + }), 770 + z.object({ 771 + bar: zNonAsciiStringæøåÆøÅöôêÊ字符串 772 + }) 773 + ]), z.object({ 774 + baz: z.union([ 775 + z.number().int().gte(0), 776 + z.null() 777 + ]), 778 + qux: z.number().int().gte(0) 779 + })); 780 + 781 + /** 782 + * An object that can be null 783 + */ 784 + export const zNullableObject = z.union([ 785 + z.object({ 786 + foo: z.string().optional() 787 + }), 788 + z.null() 789 + ]).default(null); 790 + 791 + /** 792 + * Some % character 793 + */ 794 + export const zCharactersInDescription = z.string(); 795 + 796 + export const zModelWithNullableObject = z.object({ 797 + data: zNullableObject.optional() 798 + }); 799 + 800 + export const zModelWithOneOfEnum = z.union([ 801 + z.object({ 802 + foo: z.enum([ 803 + 'Bar' 804 + ]) 805 + }), 806 + z.object({ 807 + foo: z.enum([ 808 + 'Baz' 809 + ]) 810 + }), 811 + z.object({ 812 + foo: z.enum([ 813 + 'Qux' 814 + ]) 815 + }), 816 + z.object({ 817 + content: z.string().datetime(), 818 + foo: z.enum([ 819 + 'Quux' 820 + ]) 821 + }), 822 + z.object({ 823 + content: z.tuple([ 824 + z.string().datetime(), 825 + z.string().datetime() 826 + ]), 827 + foo: z.enum([ 828 + 'Corge' 829 + ]) 830 + }) 831 + ]); 832 + 833 + export const zModelWithNestedArrayEnumsDataFoo = z.enum([ 834 + 'foo', 835 + 'bar' 836 + ]); 837 + 838 + export const zModelWithNestedArrayEnumsDataBar = z.enum([ 839 + 'baz', 840 + 'qux' 841 + ]); 842 + 843 + export const zModelWithNestedArrayEnumsData = z.object({ 844 + foo: z.array(zModelWithNestedArrayEnumsDataFoo).optional(), 845 + bar: z.array(zModelWithNestedArrayEnumsDataBar).optional() 846 + }); 847 + 848 + export const zModelWithNestedArrayEnums = z.object({ 849 + array_strings: z.array(z.string()).optional(), 850 + data: zModelWithNestedArrayEnumsData.optional() 851 + }); 852 + 853 + export const zModelWithNestedCompositionEnums = z.object({ 854 + foo: zModelWithNestedArrayEnumsDataFoo.optional() 855 + }); 856 + 857 + export const zModelWithConstantSizeArray = z.tuple([ 858 + z.number(), 859 + z.number() 860 + ]); 861 + 862 + export const zModelWithAnyOfConstantSizeArray = z.tuple([ 863 + z.union([ 864 + z.number(), 865 + z.string() 866 + ]), 867 + z.union([ 868 + z.number(), 869 + z.string() 870 + ]), 871 + z.union([ 872 + z.number(), 873 + z.string() 874 + ]) 875 + ]); 876 + 877 + export const zModelWithPrefixItemsConstantSizeArray = z.array(z.union([ 878 + zModelWithInteger, 879 + z.number(), 880 + z.string() 881 + ])); 882 + 883 + export const zModelWithAnyOfConstantSizeArrayNullable = z.tuple([ 884 + z.union([ 885 + z.number(), 886 + z.null(), 887 + z.string() 888 + ]), 889 + z.union([ 890 + z.number(), 891 + z.null(), 892 + z.string() 893 + ]), 894 + z.union([ 895 + z.number(), 896 + z.null(), 897 + z.string() 898 + ]) 899 + ]); 900 + 901 + /** 902 + * Model with restricted keyword name 903 + */ 904 + export const zImport = z.string(); 905 + 906 + export const zModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = z.tuple([ 907 + z.union([ 908 + z.number(), 909 + zImport 910 + ]), 911 + z.union([ 912 + z.number(), 913 + zImport 914 + ]) 915 + ]); 916 + 917 + export const zModelWithAnyOfConstantSizeArrayAndIntersect = z.tuple([ 918 + z.intersection(z.number(), z.string()), 919 + z.intersection(z.number(), z.string()) 920 + ]); 921 + 922 + export const zModelWithNumericEnumUnion = z.object({ 923 + value: z.unknown().optional() 924 + }); 925 + 926 + /** 927 + * Some description with `back ticks` 928 + */ 929 + export const zModelWithBackticksInDescription = z.object({ 930 + template: z.string().optional() 931 + }); 932 + 933 + export const zModelWithOneOfAndProperties = z.intersection(z.union([ 934 + zSimpleParameter, 935 + zNonAsciiStringæøåÆøÅöôêÊ字符串 936 + ]), z.object({ 937 + baz: z.union([ 938 + z.number().int().gte(0), 939 + z.null() 940 + ]), 941 + qux: z.number().int().gte(0) 942 + })); 943 + 944 + /** 945 + * Model used to test deduplication strategy (unused) 946 + */ 947 + export const zParameterSimpleParameterUnused = z.string(); 948 + 949 + /** 950 + * Model used to test deduplication strategy 951 + */ 952 + export const zPostServiceWithEmptyTagResponse = z.string(); 953 + 954 + /** 955 + * Model used to test deduplication strategy 956 + */ 957 + export const zPostServiceWithEmptyTagResponse2 = z.string(); 958 + 959 + /** 960 + * Model used to test deduplication strategy 961 + */ 962 + export const zDeleteFooData = z.string(); 963 + 964 + /** 965 + * Model used to test deduplication strategy 966 + */ 967 + export const zDeleteFooData2 = z.string(); 968 + 969 + export const zSchemaWithFormRestrictedKeys = z.object({ 970 + description: z.string().optional(), 971 + 'x-enum-descriptions': z.string().optional(), 972 + 'x-enum-varnames': z.string().optional(), 973 + 'x-enumNames': z.string().optional(), 974 + title: z.string().optional(), 975 + object: z.object({ 976 + description: z.string().optional(), 977 + 'x-enum-descriptions': z.string().optional(), 978 + 'x-enum-varnames': z.string().optional(), 979 + 'x-enumNames': z.string().optional(), 980 + title: z.string().optional() 981 + }).optional(), 982 + array: z.array(z.object({ 983 + description: z.string().optional(), 984 + 'x-enum-descriptions': z.string().optional(), 985 + 'x-enum-varnames': z.string().optional(), 986 + 'x-enumNames': z.string().optional(), 987 + title: z.string().optional() 988 + })).optional() 989 + }); 990 + 991 + /** 992 + * This schema was giving PascalCase transformations a hard time 993 + */ 994 + export const zIoK8sApimachineryPkgApisMetaV1Preconditions = z.object({ 995 + resourceVersion: z.string().optional(), 996 + uid: z.string().optional() 997 + }); 998 + 999 + /** 1000 + * This schema was giving PascalCase transformations a hard time 1001 + */ 1002 + export const zIoK8sApimachineryPkgApisMetaV1DeleteOptions = z.object({ 1003 + preconditions: zIoK8sApimachineryPkgApisMetaV1Preconditions.optional() 1004 + }); 1005 + 1006 + export const zAdditionalPropertiesUnknownIssue = z.object({}); 1007 + 1008 + export const zAdditionalPropertiesUnknownIssue2 = z.object({}); 1009 + 1010 + export const zAdditionalPropertiesUnknownIssue3 = z.intersection(z.string(), z.object({ 1011 + entries: z.object({}) 1012 + })); 1013 + 1014 + export const zAdditionalPropertiesIntegerIssue = z.object({ 1015 + value: z.number().int() 1016 + }); 1017 + 1018 + export const zGenericSchemaDuplicateIssue1SystemBoolean = z.object({ 1019 + item: z.boolean().optional(), 1020 + error: z.union([ 1021 + z.string(), 1022 + z.null() 1023 + ]).optional(), 1024 + hasError: z.boolean().readonly().optional(), 1025 + data: z.object({}).optional() 1026 + }); 1027 + 1028 + export const zGenericSchemaDuplicateIssue1SystemString = z.object({ 1029 + item: z.union([ 1030 + z.string(), 1031 + z.null() 1032 + ]).optional(), 1033 + error: z.union([ 1034 + z.string(), 1035 + z.null() 1036 + ]).optional(), 1037 + hasError: z.boolean().readonly().optional() 1038 + }); 1039 + 1040 + export const zOneOfAllOfIssue = z.union([ 1041 + z.intersection(z.union([ 1042 + zConstValue, 1043 + zGenericSchemaDuplicateIssue1SystemBoolean 1044 + ]), z3eNum1Период), 1045 + zGenericSchemaDuplicateIssue1SystemString 1046 + ]); 1047 + 1048 + /** 1049 + * Model with number-only name 1050 + */ 1051 + export const z400Writable = z.string(); 1052 + 1053 + /** 1054 + * Testing multiline comments in string: First line 1055 + * Second line 1056 + * 1057 + * Fourth line 1058 + */ 1059 + export const zCamelCaseCommentWithBreaksWritable = z.number().int(); 1060 + 1061 + /** 1062 + * Testing multiline comments in string: First line 1063 + * Second line 1064 + * 1065 + * Fourth line 1066 + */ 1067 + export const zCommentWithBreaksWritable = z.number().int(); 1068 + 1069 + /** 1070 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 1071 + */ 1072 + export const zCommentWithBackticksWritable = z.number().int(); 1073 + 1074 + /** 1075 + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 1076 + */ 1077 + export const zCommentWithBackticksAndQuotesWritable = z.number().int(); 1078 + 1079 + /** 1080 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 1081 + */ 1082 + export const zCommentWithSlashesWritable = z.number().int(); 1083 + 1084 + /** 1085 + * Testing expression placeholders in string: ${expression} should work 1086 + */ 1087 + export const zCommentWithExpressionPlaceholdersWritable = z.number().int(); 1088 + 1089 + /** 1090 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 1091 + */ 1092 + export const zCommentWithQuotesWritable = z.number().int(); 1093 + 1094 + /** 1095 + * Testing reserved characters in string: * inline * and ** inline ** should work 1096 + */ 1097 + export const zCommentWithReservedCharactersWritable = z.number().int(); 1098 + 1099 + /** 1100 + * This is a simple number 1101 + */ 1102 + export const zSimpleIntegerWritable = z.number().int(); 1103 + 1104 + /** 1105 + * This is a simple boolean 1106 + */ 1107 + export const zSimpleBooleanWritable = z.boolean(); 1108 + 1109 + /** 1110 + * This is a simple string 1111 + */ 1112 + export const zSimpleStringWritable = z.string(); 1113 + 1114 + /** 1115 + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 1116 + */ 1117 + export const zNonAsciiStringæøåÆøÅöôêÊ字符串Writable = z.string(); 1118 + 1119 + /** 1120 + * This is a simple file 1121 + */ 1122 + export const zSimpleFileWritable = z.string(); 1123 + 1124 + /** 1125 + * This is a simple string 1126 + */ 1127 + export const zSimpleStringWithPatternWritable = z.union([ 1128 + z.string().max(64).regex(/^[a-zA-Z0-9_]*$/), 1129 + z.null() 1130 + ]); 1131 + 1132 + /** 1133 + * This is a simple enum with strings 1134 + */ 1135 + export const zEnumWithStringsWritable = z.enum([ 1136 + 'Success', 1137 + 'Warning', 1138 + 'Error', 1139 + "'Single Quote'", 1140 + '"Double Quotes"', 1141 + 'Non-ascii: øæåôöØÆÅÔÖ字符串' 1142 + ]); 1143 + 1144 + export const zEnumWithReplacedCharactersWritable = z.enum([ 1145 + "'Single Quote'", 1146 + '"Double Quotes"', 1147 + 'øæåôöØÆÅÔÖ字符串', 1148 + '' 1149 + ]); 1150 + 1151 + /** 1152 + * This is a simple enum with numbers 1153 + */ 1154 + export const zEnumWithNumbersWritable = z.unknown(); 1155 + 1156 + /** 1157 + * Success=1,Warning=2,Error=3 1158 + */ 1159 + export const zEnumFromDescriptionWritable = z.number(); 1160 + 1161 + /** 1162 + * This is a simple enum with numbers 1163 + */ 1164 + export const zEnumWithExtensionsWritable = z.unknown(); 1165 + 1166 + export const zEnumWithXEnumNamesWritable = z.unknown(); 1167 + 1168 + /** 1169 + * This is a simple array with numbers 1170 + */ 1171 + export const zArrayWithNumbersWritable = z.array(z.number().int()); 1172 + 1173 + /** 1174 + * This is a simple array with booleans 1175 + */ 1176 + export const zArrayWithBooleansWritable = z.array(z.boolean()); 1177 + 1178 + /** 1179 + * This is a simple array with strings 1180 + */ 1181 + export const zArrayWithStringsWritable = z.array(z.string()).default(['test']); 1182 + 1183 + /** 1184 + * This is a string dictionary 1185 + */ 1186 + export const zDictionaryWithStringWritable = z.object({}); 1187 + 1188 + /** 1189 + * This is a string dictionary 1190 + */ 1191 + export const zDictionaryWithDictionaryWritable = z.record(z.object({})); 1192 + 1193 + /** 1194 + * `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) 1195 + */ 1196 + export const zModelFromZendeskWritable = z.string(); 1197 + 1198 + export const zModelWithReadOnlyAndWriteOnlyWritable = z.object({ 1199 + foo: z.string(), 1200 + baz: z.string() 1201 + }); 1202 + 1203 + /** 1204 + * This is a model with one property containing an array 1205 + */ 1206 + export const zModelWithArrayReadOnlyAndWriteOnlyWritable = z.object({ 1207 + prop: z.array(zModelWithReadOnlyAndWriteOnlyWritable).optional(), 1208 + propWithFile: z.array(z.string()).optional(), 1209 + propWithNumber: z.array(z.number()).optional() 1210 + }); 1211 + 1212 + export const z3eNum1ПериодWritable = z.enum([ 1213 + 'Bird', 1214 + 'Dog' 1215 + ]); 1216 + 1217 + export const zConstValueWritable = z.enum([ 1218 + 'ConstValue' 1219 + ]); 1220 + 1221 + /** 1222 + * This is a free-form object without additionalProperties. 1223 + */ 1224 + export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.object({}); 1225 + 1226 + /** 1227 + * This is a free-form object with additionalProperties: true. 1228 + */ 1229 + export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.object({}); 1230 + 1231 + /** 1232 + * This is a free-form object with additionalProperties: {}. 1233 + */ 1234 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.object({}); 1235 + 1236 + /** 1237 + * Some % character 1238 + */ 1239 + export const zCharactersInDescriptionWritable = z.string(); 1240 + 1241 + export const zModelWithNestedArrayEnumsDataFooWritable = z.enum([ 1242 + 'foo', 1243 + 'bar' 1244 + ]); 1245 + 1246 + export const zModelWithNestedArrayEnumsDataBarWritable = z.enum([ 1247 + 'baz', 1248 + 'qux' 1249 + ]); 1250 + 1251 + export const zModelWithConstantSizeArrayWritable = z.tuple([ 1252 + z.number(), 1253 + z.number() 1254 + ]); 1255 + 1256 + export const zModelWithAnyOfConstantSizeArrayWritable = z.tuple([ 1257 + z.union([ 1258 + z.number(), 1259 + z.string() 1260 + ]), 1261 + z.union([ 1262 + z.number(), 1263 + z.string() 1264 + ]), 1265 + z.union([ 1266 + z.number(), 1267 + z.string() 1268 + ]) 1269 + ]); 1270 + 1271 + export const zModelWithAnyOfConstantSizeArrayNullableWritable = z.tuple([ 1272 + z.union([ 1273 + z.number(), 1274 + z.null(), 1275 + z.string() 1276 + ]), 1277 + z.union([ 1278 + z.number(), 1279 + z.null(), 1280 + z.string() 1281 + ]), 1282 + z.union([ 1283 + z.number(), 1284 + z.null(), 1285 + z.string() 1286 + ]) 1287 + ]); 1288 + 1289 + /** 1290 + * Model with restricted keyword name 1291 + */ 1292 + export const zImportWritable = z.string(); 1293 + 1294 + export const zModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = z.tuple([ 1295 + z.union([ 1296 + z.number(), 1297 + zImportWritable 1298 + ]), 1299 + z.union([ 1300 + z.number(), 1301 + zImportWritable 1302 + ]) 1303 + ]); 1304 + 1305 + export const zModelWithAnyOfConstantSizeArrayAndIntersectWritable = z.tuple([ 1306 + z.intersection(z.number(), z.string()), 1307 + z.intersection(z.number(), z.string()) 1308 + ]); 1309 + 1310 + /** 1311 + * Model used to test deduplication strategy (unused) 1312 + */ 1313 + export const zParameterSimpleParameterUnusedWritable = z.string(); 1314 + 1315 + /** 1316 + * Model used to test deduplication strategy 1317 + */ 1318 + export const zPostServiceWithEmptyTagResponseWritable = z.string(); 1319 + 1320 + /** 1321 + * Model used to test deduplication strategy 1322 + */ 1323 + export const zPostServiceWithEmptyTagResponse2Writable = z.string(); 1324 + 1325 + /** 1326 + * Model used to test deduplication strategy 1327 + */ 1328 + export const zDeleteFooDataWritable = z.string(); 1329 + 1330 + /** 1331 + * Model used to test deduplication strategy 1332 + */ 1333 + export const zDeleteFooData2Writable = z.string(); 1334 + 1335 + export const zAdditionalPropertiesUnknownIssueWritable = z.object({}); 1336 + 1337 + export const zAdditionalPropertiesUnknownIssue2Writable = z.object({}); 1338 + 1339 + export const zOneOfAllOfIssueWritable = z.union([ 1340 + z.intersection(z.union([ 1341 + zConstValueWritable, 1342 + zGenericSchemaDuplicateIssue1SystemBoolean 1343 + ]), z3eNum1Период), 1344 + zGenericSchemaDuplicateIssue1SystemString 1345 + ]); 1346 + 1347 + /** 1348 + * Parameter with illegal characters 1349 + */ 1350 + export const zXFooBar = zModelWithString; 1351 + 1352 + export const zSimpleRequestBody = zModelWithString; 1353 + 1354 + export const zSimpleFormData = zModelWithString; 1355 + 1356 + export const zExportData = z.object({ 1357 + body: z.never().optional(), 1358 + path: z.never().optional(), 1359 + query: z.never().optional() 1360 + }); 1361 + 1362 + export const zPatchApiVbyApiVersionNoTagData = z.object({ 1363 + body: z.never().optional(), 1364 + path: z.never().optional(), 1365 + query: z.never().optional() 1366 + }); 1367 + 1368 + export const zImportData = z.object({ 1369 + body: z.union([ 1370 + zModelWithReadOnlyAndWriteOnlyWritable, 1371 + zModelWithArrayReadOnlyAndWriteOnlyWritable 1372 + ]), 1373 + path: z.never().optional(), 1374 + query: z.never().optional() 1375 + }); 1376 + 1377 + export const zImportResponse = z.union([ 1378 + zModelFromZendesk, 1379 + zModelWithReadOnlyAndWriteOnly 1380 + ]); 1381 + 1382 + export const zFooWowData = z.object({ 1383 + body: z.never().optional(), 1384 + path: z.never().optional(), 1385 + query: z.never().optional() 1386 + }); 1387 + 1388 + export const zApiVVersionODataControllerCountData = z.object({ 1389 + body: z.never().optional(), 1390 + path: z.never().optional(), 1391 + query: z.never().optional() 1392 + }); 1393 + 1394 + /** 1395 + * Success 1396 + */ 1397 + export const zApiVVersionODataControllerCountResponse = zModelFromZendesk; 1398 + 1399 + export const zGetApiVbyApiVersionSimpleOperationData = z.object({ 1400 + body: z.never().optional(), 1401 + path: z.object({ 1402 + foo_param: z.string() 1403 + }), 1404 + query: z.never().optional() 1405 + }); 1406 + 1407 + /** 1408 + * Response is a simple number 1409 + */ 1410 + export const zGetApiVbyApiVersionSimpleOperationResponse = z.number(); 1411 + 1412 + export const zDeleteCallWithoutParametersAndResponseData = z.object({ 1413 + body: z.never().optional(), 1414 + path: z.never().optional(), 1415 + query: z.never().optional() 1416 + }); 1417 + 1418 + export const zGetCallWithoutParametersAndResponseData = z.object({ 1419 + body: z.never().optional(), 1420 + path: z.never().optional(), 1421 + query: z.never().optional() 1422 + }); 1423 + 1424 + export const zHeadCallWithoutParametersAndResponseData = z.object({ 1425 + body: z.never().optional(), 1426 + path: z.never().optional(), 1427 + query: z.never().optional() 1428 + }); 1429 + 1430 + export const zOptionsCallWithoutParametersAndResponseData = z.object({ 1431 + body: z.never().optional(), 1432 + path: z.never().optional(), 1433 + query: z.never().optional() 1434 + }); 1435 + 1436 + export const zPatchCallWithoutParametersAndResponseData = z.object({ 1437 + body: z.never().optional(), 1438 + path: z.never().optional(), 1439 + query: z.never().optional() 1440 + }); 1441 + 1442 + export const zPostCallWithoutParametersAndResponseData = z.object({ 1443 + body: z.never().optional(), 1444 + path: z.never().optional(), 1445 + query: z.never().optional() 1446 + }); 1447 + 1448 + export const zPutCallWithoutParametersAndResponseData = z.object({ 1449 + body: z.never().optional(), 1450 + path: z.never().optional(), 1451 + query: z.never().optional() 1452 + }); 1453 + 1454 + export const zDeleteFooData3 = z.object({ 1455 + body: z.never().optional(), 1456 + path: z.object({ 1457 + foo_param: z.string(), 1458 + BarParam: z.string() 1459 + }), 1460 + query: z.never().optional(), 1461 + headers: z.object({ 1462 + 'x-Foo-Bar': zModelWithString 1463 + }) 1464 + }); 1465 + 1466 + export const zCallWithDescriptionsData = z.object({ 1467 + body: z.never().optional(), 1468 + path: z.never().optional(), 1469 + query: z.object({ 1470 + parameterWithBreaks: z.string().optional(), 1471 + parameterWithBackticks: z.string().optional(), 1472 + parameterWithSlashes: z.string().optional(), 1473 + parameterWithExpressionPlaceholders: z.string().optional(), 1474 + parameterWithQuotes: z.string().optional(), 1475 + parameterWithReservedCharacters: z.string().optional() 1476 + }).optional() 1477 + }); 1478 + 1479 + export const zDeprecatedCallData = z.object({ 1480 + body: z.never().optional(), 1481 + path: z.never().optional(), 1482 + query: z.never().optional(), 1483 + headers: z.object({ 1484 + parameter: z.union([ 1485 + zDeprecatedModel, 1486 + z.null() 1487 + ]) 1488 + }) 1489 + }); 1490 + 1491 + export const zCallWithParametersData = z.object({ 1492 + body: z.union([ 1493 + z.object({}), 1494 + z.null() 1495 + ]), 1496 + path: z.object({ 1497 + parameterPath: z.union([ 1498 + z.string(), 1499 + z.null() 1500 + ]), 1501 + 'api-version': z.union([ 1502 + z.string(), 1503 + z.null() 1504 + ]) 1505 + }), 1506 + query: z.object({ 1507 + foo_ref_enum: zModelWithNestedArrayEnumsDataFooWritable.optional(), 1508 + foo_all_of_enum: zModelWithNestedArrayEnumsDataFooWritable, 1509 + cursor: z.union([ 1510 + z.string(), 1511 + z.null() 1512 + ]) 1513 + }), 1514 + headers: z.object({ 1515 + parameterHeader: z.union([ 1516 + z.string(), 1517 + z.null() 1518 + ]) 1519 + }) 1520 + }); 1521 + 1522 + export const zCallWithWeirdParameterNamesData = z.object({ 1523 + body: z.union([ 1524 + zModelWithString, 1525 + z.null() 1526 + ]), 1527 + path: z.object({ 1528 + 'parameter.path.1': z.string().optional(), 1529 + 'parameter-path-2': z.string().optional(), 1530 + 'PARAMETER-PATH-3': z.string().optional(), 1531 + 'api-version': z.union([ 1532 + z.string(), 1533 + z.null() 1534 + ]) 1535 + }), 1536 + query: z.object({ 1537 + default: z.string().optional(), 1538 + 'parameter-query': z.union([ 1539 + z.string(), 1540 + z.null() 1541 + ]) 1542 + }), 1543 + headers: z.object({ 1544 + 'parameter.header': z.union([ 1545 + z.string(), 1546 + z.null() 1547 + ]) 1548 + }) 1549 + }); 1550 + 1551 + export const zGetCallWithOptionalParamData = z.object({ 1552 + body: zModelWithOneOfEnum, 1553 + path: z.never().optional(), 1554 + query: z.object({ 1555 + page: z.number().optional() 1556 + }).optional() 1557 + }); 1558 + 1559 + export const zPostCallWithOptionalParamData = z.object({ 1560 + body: z.object({ 1561 + offset: z.union([ 1562 + z.number(), 1563 + z.null() 1564 + ]).optional() 1565 + }).optional(), 1566 + path: z.never().optional(), 1567 + query: z.object({ 1568 + parameter: zPageable 1569 + }) 1570 + }); 1571 + 1572 + export const zPostCallWithOptionalParamResponse = z.union([ 1573 + z.number(), 1574 + z.void() 1575 + ]); 1576 + 1577 + export const zPostApiVbyApiVersionRequestBodyData = z.object({ 1578 + body: zSimpleRequestBody.optional(), 1579 + path: z.never().optional(), 1580 + query: z.object({ 1581 + parameter: z.string().optional() 1582 + }).optional() 1583 + }); 1584 + 1585 + export const zPostApiVbyApiVersionFormDataData = z.object({ 1586 + body: zSimpleFormData.optional(), 1587 + path: z.never().optional(), 1588 + query: z.object({ 1589 + parameter: z.string().optional() 1590 + }).optional() 1591 + }); 1592 + 1593 + export const zCallWithDefaultParametersData = z.object({ 1594 + body: z.never().optional(), 1595 + path: z.never().optional(), 1596 + query: z.object({ 1597 + parameterString: z.union([ 1598 + z.string().default('Hello World!'), 1599 + z.null() 1600 + ]).optional().default('Hello World!'), 1601 + parameterNumber: z.union([ 1602 + z.number().default(123), 1603 + z.null() 1604 + ]).optional().default(123), 1605 + parameterBoolean: z.union([ 1606 + z.boolean().default(true), 1607 + z.null() 1608 + ]).optional().default(true), 1609 + parameterEnum: z.enum([ 1610 + 'Success', 1611 + 'Warning', 1612 + 'Error' 1613 + ]).optional(), 1614 + parameterModel: z.union([ 1615 + zModelWithString, 1616 + z.null() 1617 + ]).optional() 1618 + }).optional() 1619 + }); 1620 + 1621 + export const zCallWithDefaultOptionalParametersData = z.object({ 1622 + body: z.never().optional(), 1623 + path: z.never().optional(), 1624 + query: z.object({ 1625 + parameterString: z.string().optional().default('Hello World!'), 1626 + parameterNumber: z.number().optional().default(123), 1627 + parameterBoolean: z.boolean().optional().default(true), 1628 + parameterEnum: z.enum([ 1629 + 'Success', 1630 + 'Warning', 1631 + 'Error' 1632 + ]).optional(), 1633 + parameterModel: zModelWithString.optional() 1634 + }).optional() 1635 + }); 1636 + 1637 + export const zCallToTestOrderOfParamsData = z.object({ 1638 + body: z.never().optional(), 1639 + path: z.never().optional(), 1640 + query: z.object({ 1641 + parameterOptionalStringWithDefault: z.string().optional().default('Hello World!'), 1642 + parameterOptionalStringWithEmptyDefault: z.string().optional().default(''), 1643 + parameterOptionalStringWithNoDefault: z.string().optional(), 1644 + parameterStringWithDefault: z.string().default('Hello World!'), 1645 + parameterStringWithEmptyDefault: z.string().default(''), 1646 + parameterStringWithNoDefault: z.string(), 1647 + parameterStringNullableWithNoDefault: z.union([ 1648 + z.string(), 1649 + z.null() 1650 + ]).optional(), 1651 + parameterStringNullableWithDefault: z.union([ 1652 + z.string(), 1653 + z.null() 1654 + ]).optional().default(null) 1655 + }) 1656 + }); 1657 + 1658 + export const zDuplicateNameData = z.object({ 1659 + body: z.never().optional(), 1660 + path: z.never().optional(), 1661 + query: z.never().optional() 1662 + }); 1663 + 1664 + export const zDuplicateName2Data = z.object({ 1665 + body: z.never().optional(), 1666 + path: z.never().optional(), 1667 + query: z.never().optional() 1668 + }); 1669 + 1670 + export const zDuplicateName3Data = z.object({ 1671 + body: z.never().optional(), 1672 + path: z.never().optional(), 1673 + query: z.never().optional() 1674 + }); 1675 + 1676 + export const zDuplicateName4Data = z.object({ 1677 + body: z.never().optional(), 1678 + path: z.never().optional(), 1679 + query: z.never().optional() 1680 + }); 1681 + 1682 + export const zCallWithNoContentResponseData = z.object({ 1683 + body: z.never().optional(), 1684 + path: z.never().optional(), 1685 + query: z.never().optional() 1686 + }); 1687 + 1688 + /** 1689 + * Success 1690 + */ 1691 + export const zCallWithNoContentResponseResponse = z.void(); 1692 + 1693 + export const zCallWithResponseAndNoContentResponseData = z.object({ 1694 + body: z.never().optional(), 1695 + path: z.never().optional(), 1696 + query: z.never().optional() 1697 + }); 1698 + 1699 + export const zCallWithResponseAndNoContentResponseResponse = z.union([ 1700 + z.number(), 1701 + z.void() 1702 + ]); 1703 + 1704 + export const zDummyAData = z.object({ 1705 + body: z.never().optional(), 1706 + path: z.never().optional(), 1707 + query: z.never().optional() 1708 + }); 1709 + 1710 + export const zDummyAResponse = z400; 1711 + 1712 + export const zDummyBData = z.object({ 1713 + body: z.never().optional(), 1714 + path: z.never().optional(), 1715 + query: z.never().optional() 1716 + }); 1717 + 1718 + /** 1719 + * Success 1720 + */ 1721 + export const zDummyBResponse = z.void(); 1722 + 1723 + export const zCallWithResponseData = z.object({ 1724 + body: z.never().optional(), 1725 + path: z.never().optional(), 1726 + query: z.never().optional() 1727 + }); 1728 + 1729 + export const zCallWithResponseResponse = zImport; 1730 + 1731 + export const zCallWithDuplicateResponsesData = z.object({ 1732 + body: z.never().optional(), 1733 + path: z.never().optional(), 1734 + query: z.never().optional() 1735 + }); 1736 + 1737 + export const zCallWithDuplicateResponsesResponse = z.union([ 1738 + zModelWithBoolean.and(zModelWithInteger), 1739 + zModelWithString 1740 + ]); 1741 + 1742 + export const zCallWithResponsesData = z.object({ 1743 + body: z.never().optional(), 1744 + path: z.never().optional(), 1745 + query: z.never().optional() 1746 + }); 1747 + 1748 + export const zCallWithResponsesResponse = z.union([ 1749 + z.object({ 1750 + '@namespace.string': z.string().readonly().optional(), 1751 + '@namespace.integer': z.number().int().readonly().optional(), 1752 + value: z.array(zModelWithString).readonly().optional() 1753 + }), 1754 + zModelThatExtends, 1755 + zModelThatExtendsExtends 1756 + ]); 1757 + 1758 + export const zCollectionFormatData = z.object({ 1759 + body: z.never().optional(), 1760 + path: z.never().optional(), 1761 + query: z.object({ 1762 + parameterArrayCSV: z.union([ 1763 + z.array(z.string()), 1764 + z.null() 1765 + ]), 1766 + parameterArraySSV: z.union([ 1767 + z.array(z.string()), 1768 + z.null() 1769 + ]), 1770 + parameterArrayTSV: z.union([ 1771 + z.array(z.string()), 1772 + z.null() 1773 + ]), 1774 + parameterArrayPipes: z.union([ 1775 + z.array(z.string()), 1776 + z.null() 1777 + ]), 1778 + parameterArrayMulti: z.union([ 1779 + z.array(z.string()), 1780 + z.null() 1781 + ]) 1782 + }) 1783 + }); 1784 + 1785 + export const zTypesData = z.object({ 1786 + body: z.never().optional(), 1787 + path: z.object({ 1788 + id: z.number().int().optional() 1789 + }).optional(), 1790 + query: z.object({ 1791 + parameterNumber: z.number().default(123), 1792 + parameterString: z.union([ 1793 + z.string().default('default'), 1794 + z.null() 1795 + ]).default('default'), 1796 + parameterBoolean: z.union([ 1797 + z.boolean().default(true), 1798 + z.null() 1799 + ]).default(true), 1800 + parameterObject: z.union([ 1801 + z.object({}), 1802 + z.null() 1803 + ]).default(null), 1804 + parameterArray: z.union([ 1805 + z.array(z.string()), 1806 + z.null() 1807 + ]), 1808 + parameterDictionary: z.union([ 1809 + z.object({}), 1810 + z.null() 1811 + ]), 1812 + parameterEnum: z.enum([ 1813 + 'Success', 1814 + 'Warning', 1815 + 'Error' 1816 + ]) 1817 + }) 1818 + }); 1819 + 1820 + export const zTypesResponse = z.union([ 1821 + z.number(), 1822 + z.string(), 1823 + z.boolean(), 1824 + z.object({}) 1825 + ]); 1826 + 1827 + export const zUploadFileData = z.object({ 1828 + body: z.string(), 1829 + path: z.object({ 1830 + 'api-version': z.union([ 1831 + z.string(), 1832 + z.null() 1833 + ]) 1834 + }), 1835 + query: z.never().optional() 1836 + }); 1837 + 1838 + export const zUploadFileResponse = z.boolean(); 1839 + 1840 + export const zFileResponseData = z.object({ 1841 + body: z.never().optional(), 1842 + path: z.object({ 1843 + id: z.string(), 1844 + 'api-version': z.string() 1845 + }), 1846 + query: z.never().optional() 1847 + }); 1848 + 1849 + /** 1850 + * Success 1851 + */ 1852 + export const zFileResponseResponse = z.string(); 1853 + 1854 + export const zComplexTypesData = z.object({ 1855 + body: z.never().optional(), 1856 + path: z.never().optional(), 1857 + query: z.object({ 1858 + parameterObject: z.object({ 1859 + first: z.object({ 1860 + second: z.object({ 1861 + third: z.string().optional() 1862 + }).optional() 1863 + }).optional() 1864 + }), 1865 + parameterReference: zModelWithString 1866 + }) 1867 + }); 1868 + 1869 + /** 1870 + * Successful response 1871 + */ 1872 + export const zComplexTypesResponse = z.array(zModelWithString); 1873 + 1874 + export const zMultipartResponseData = z.object({ 1875 + body: z.never().optional(), 1876 + path: z.never().optional(), 1877 + query: z.never().optional() 1878 + }); 1879 + 1880 + /** 1881 + * OK 1882 + */ 1883 + export const zMultipartResponseResponse = z.object({ 1884 + file: z.string().optional(), 1885 + metadata: z.object({ 1886 + foo: z.string().optional(), 1887 + bar: z.string().optional() 1888 + }).optional() 1889 + }); 1890 + 1891 + export const zMultipartRequestData = z.object({ 1892 + body: z.object({ 1893 + content: z.string().optional(), 1894 + data: z.union([ 1895 + zModelWithString, 1896 + z.null() 1897 + ]).optional() 1898 + }).optional(), 1899 + path: z.never().optional(), 1900 + query: z.never().optional() 1901 + }); 1902 + 1903 + export const zComplexParamsData = z.object({ 1904 + body: z.object({ 1905 + key: z.union([ 1906 + z.string().max(64).regex(/^[a-zA-Z0-9_]*$/).readonly(), 1907 + z.null() 1908 + ]).readonly(), 1909 + name: z.union([ 1910 + z.string().max(255), 1911 + z.null() 1912 + ]), 1913 + enabled: z.boolean().optional().default(true), 1914 + type: z.enum([ 1915 + 'Monkey', 1916 + 'Horse', 1917 + 'Bird' 1918 + ]), 1919 + listOfModels: z.union([ 1920 + z.array(zModelWithString), 1921 + z.null() 1922 + ]).optional(), 1923 + listOfStrings: z.union([ 1924 + z.array(z.string()), 1925 + z.null() 1926 + ]).optional(), 1927 + parameters: z.union([ 1928 + zModelWithString, 1929 + zModelWithEnum, 1930 + zModelWithArray, 1931 + zModelWithDictionary 1932 + ]), 1933 + user: z.object({ 1934 + id: z.number().int().readonly().optional(), 1935 + name: z.union([ 1936 + z.string().readonly(), 1937 + z.null() 1938 + ]).readonly().optional() 1939 + }).readonly().optional() 1940 + }).optional(), 1941 + path: z.object({ 1942 + id: z.number().int(), 1943 + 'api-version': z.string() 1944 + }), 1945 + query: z.never().optional() 1946 + }); 1947 + 1948 + /** 1949 + * Success 1950 + */ 1951 + export const zComplexParamsResponse = zModelWithString; 1952 + 1953 + export const zCallWithResultFromHeaderData = z.object({ 1954 + body: z.never().optional(), 1955 + path: z.never().optional(), 1956 + query: z.never().optional() 1957 + }); 1958 + 1959 + export const zTestErrorCodeData = z.object({ 1960 + body: z.never().optional(), 1961 + path: z.never().optional(), 1962 + query: z.object({ 1963 + status: z.number().int() 1964 + }) 1965 + }); 1966 + 1967 + export const zNonAsciiæøåÆøÅöôêÊ字符串Data = z.object({ 1968 + body: z.never().optional(), 1969 + path: z.never().optional(), 1970 + query: z.object({ 1971 + 'nonAsciiParamæøåÆØÅöôêÊ': z.number().int() 1972 + }) 1973 + }); 1974 + 1975 + /** 1976 + * Successful response 1977 + */ 1978 + export const zNonAsciiæøåÆøÅöôêÊ字符串Response = z.array(zNonAsciiStringæøåÆøÅöôêÊ字符串); 1979 + 1980 + export const zPutWithFormUrlEncodedData = z.object({ 1981 + body: zArrayWithStringsWritable, 1982 + path: z.never().optional(), 1983 + query: z.never().optional() 1984 + });
+24
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/type-format-zod/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod/v3'; 4 + 5 + export const zFoo = z.object({ 6 + bar: z.number().int().optional(), 7 + foo: z.coerce.bigint().default(BigInt(0)), 8 + id: z.string() 9 + }); 10 + 11 + export const zBar = z.object({ 12 + foo: z.number().int() 13 + }); 14 + 15 + export const zPostFooData = z.object({ 16 + body: z.never().optional(), 17 + path: z.never().optional(), 18 + query: z.never().optional() 19 + }); 20 + 21 + /** 22 + * OK 23 + */ 24 + export const zPostFooResponse = zFoo;
+23
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v3/validators/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod/v3'; 4 + 5 + export const zBar: z.AnyZodObject = z.object({ 6 + foo: z.lazy(() => { 7 + return zFoo; 8 + }).optional() 9 + }); 10 + 11 + export const zFoo: z.ZodTypeAny = z.union([ 12 + z.object({ 13 + foo: z.string().regex(/^\d{3}-\d{2}-\d{4}$/).optional(), 14 + bar: zBar.optional(), 15 + baz: z.array(z.lazy(() => { 16 + return zFoo; 17 + })).optional(), 18 + qux: z.number().int().gt(0).optional().default(0) 19 + }), 20 + z.null() 21 + ]).default(null); 22 + 23 + export const zBaz = z.string().regex(/foo\nbar/).readonly().default('baz');
+18
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/enum-null/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod'; 4 + 5 + export const zFoo = z.nullable(z.enum([ 6 + 'foo', 7 + 'bar' 8 + ])); 9 + 10 + export const zBar = z.enum([ 11 + 'foo', 12 + 'bar' 13 + ]); 14 + 15 + export const zBaz = z.enum([ 16 + 'foo', 17 + 'bar' 18 + ]);
+24
packages/openapi-ts-tests/zod/v4/__snapshots__/3.0.x/v4/type-format-zod/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod'; 4 + 5 + export const zFoo = z.object({ 6 + bar: z.optional(z.int()), 7 + foo: z.coerce.bigint().default(BigInt(0)), 8 + id: z.string() 9 + }); 10 + 11 + export const zBar = z.object({ 12 + foo: z.int() 13 + }); 14 + 15 + export const zPostFooData = z.object({ 16 + body: z.optional(z.never()), 17 + path: z.optional(z.never()), 18 + query: z.optional(z.never()) 19 + }); 20 + 21 + /** 22 + * OK 23 + */ 24 + export const zPostFooResponse = zFoo;
+9
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/array-items-one-of-length-1/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as z from 'zod/mini'; 4 + 5 + export const zBar = z.string(); 6 + 7 + export const zFoo = z.object({ 8 + foo: z.optional(z.array(zBar).check(z.minLength(1), z.maxLength(2147483647))) 9 + });
+1994
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/default/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as z from 'zod/mini'; 4 + 5 + /** 6 + * Model with number-only name 7 + */ 8 + export const z400 = z.string(); 9 + 10 + /** 11 + * Testing multiline comments in string: First line 12 + * Second line 13 + * 14 + * Fourth line 15 + */ 16 + export const zCamelCaseCommentWithBreaks = z.int(); 17 + 18 + /** 19 + * Testing multiline comments in string: First line 20 + * Second line 21 + * 22 + * Fourth line 23 + */ 24 + export const zCommentWithBreaks = z.int(); 25 + 26 + /** 27 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 28 + */ 29 + export const zCommentWithBackticks = z.int(); 30 + 31 + /** 32 + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 33 + */ 34 + export const zCommentWithBackticksAndQuotes = z.int(); 35 + 36 + /** 37 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 38 + */ 39 + export const zCommentWithSlashes = z.int(); 40 + 41 + /** 42 + * Testing expression placeholders in string: ${expression} should work 43 + */ 44 + export const zCommentWithExpressionPlaceholders = z.int(); 45 + 46 + /** 47 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 48 + */ 49 + export const zCommentWithQuotes = z.int(); 50 + 51 + /** 52 + * Testing reserved characters in string: * inline * and ** inline ** should work 53 + */ 54 + export const zCommentWithReservedCharacters = z.int(); 55 + 56 + /** 57 + * This is a simple number 58 + */ 59 + export const zSimpleInteger = z.int(); 60 + 61 + /** 62 + * This is a simple boolean 63 + */ 64 + export const zSimpleBoolean = z.boolean(); 65 + 66 + /** 67 + * This is a simple string 68 + */ 69 + export const zSimpleString = z.string(); 70 + 71 + /** 72 + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 73 + */ 74 + export const zNonAsciiStringæøåÆøÅöôêÊ字符串 = z.string(); 75 + 76 + /** 77 + * This is a simple file 78 + */ 79 + export const zSimpleFile = z.string(); 80 + 81 + /** 82 + * This is a model with one string property 83 + */ 84 + export const zModelWithString = z.object({ 85 + prop: z.optional(z.string()) 86 + }); 87 + 88 + /** 89 + * This is a simple reference 90 + */ 91 + export const zSimpleReference = zModelWithString; 92 + 93 + /** 94 + * This is a simple string 95 + */ 96 + export const zSimpleStringWithPattern = z.union([ 97 + z.string().check(z.maxLength(64), z.regex(/^[a-zA-Z0-9_]*$/)), 98 + z.null() 99 + ]); 100 + 101 + /** 102 + * This is a simple enum with strings 103 + */ 104 + export const zEnumWithStrings = z.enum([ 105 + 'Success', 106 + 'Warning', 107 + 'Error', 108 + "'Single Quote'", 109 + '"Double Quotes"', 110 + 'Non-ascii: øæåôöØÆÅÔÖ字符串' 111 + ]); 112 + 113 + export const zEnumWithReplacedCharacters = z.enum([ 114 + "'Single Quote'", 115 + '"Double Quotes"', 116 + 'øæåôöØÆÅÔÖ字符串', 117 + '' 118 + ]); 119 + 120 + /** 121 + * This is a simple enum with numbers 122 + */ 123 + export const zEnumWithNumbers = z.unknown(); 124 + 125 + /** 126 + * Success=1,Warning=2,Error=3 127 + */ 128 + export const zEnumFromDescription = z.number(); 129 + 130 + /** 131 + * This is a simple enum with numbers 132 + */ 133 + export const zEnumWithExtensions = z.unknown(); 134 + 135 + export const zEnumWithXEnumNames = z.unknown(); 136 + 137 + /** 138 + * This is a simple array with numbers 139 + */ 140 + export const zArrayWithNumbers = z.array(z.int()); 141 + 142 + /** 143 + * This is a simple array with booleans 144 + */ 145 + export const zArrayWithBooleans = z.array(z.boolean()); 146 + 147 + /** 148 + * This is a simple array with strings 149 + */ 150 + export const zArrayWithStrings = z._default(z.array(z.string()), ['test']); 151 + 152 + /** 153 + * This is a simple array with references 154 + */ 155 + export const zArrayWithReferences = z.array(zModelWithString); 156 + 157 + /** 158 + * This is a simple array containing an array 159 + */ 160 + export const zArrayWithArray = z.array(z.array(zModelWithString)); 161 + 162 + /** 163 + * This is a simple array with properties 164 + */ 165 + export const zArrayWithProperties = z.array(z.object({ 166 + '16x16': z.optional(zCamelCaseCommentWithBreaks), 167 + bar: z.optional(z.string()) 168 + })); 169 + 170 + /** 171 + * This is a simple array with any of properties 172 + */ 173 + export const zArrayWithAnyOfProperties = z.array(z.union([ 174 + z.object({ 175 + foo: z._default(z.optional(z.string()), 'test') 176 + }), 177 + z.object({ 178 + bar: z.optional(z.string()) 179 + }) 180 + ])); 181 + 182 + export const zAnyOfAnyAndNull = z.object({ 183 + data: z.optional(z.union([ 184 + z.unknown(), 185 + z.null() 186 + ])) 187 + }); 188 + 189 + /** 190 + * This is a simple array with any of properties 191 + */ 192 + export const zAnyOfArrays = z.object({ 193 + results: z.optional(z.array(z.union([ 194 + z.object({ 195 + foo: z.optional(z.string()) 196 + }), 197 + z.object({ 198 + bar: z.optional(z.string()) 199 + }) 200 + ]))) 201 + }); 202 + 203 + /** 204 + * This is a string dictionary 205 + */ 206 + export const zDictionaryWithString = z.object({}); 207 + 208 + export const zDictionaryWithPropertiesAndAdditionalProperties = z.object({ 209 + foo: z.optional(z.number()), 210 + bar: z.optional(z.boolean()) 211 + }); 212 + 213 + /** 214 + * This is a string reference 215 + */ 216 + export const zDictionaryWithReference = z.object({}); 217 + 218 + /** 219 + * This is a complex dictionary 220 + */ 221 + export const zDictionaryWithArray = z.object({}); 222 + 223 + /** 224 + * This is a string dictionary 225 + */ 226 + export const zDictionaryWithDictionary = z.record(z.string(), z.object({})); 227 + 228 + /** 229 + * This is a complex dictionary 230 + */ 231 + export const zDictionaryWithProperties = z.record(z.string(), z.object({ 232 + foo: z.optional(z.string()), 233 + bar: z.optional(z.string()) 234 + })); 235 + 236 + /** 237 + * This is a model with one number property 238 + */ 239 + export const zModelWithInteger = z.object({ 240 + prop: z.optional(z.int()) 241 + }); 242 + 243 + /** 244 + * This is a model with one boolean property 245 + */ 246 + export const zModelWithBoolean = z.object({ 247 + prop: z.optional(z.boolean()) 248 + }); 249 + 250 + /** 251 + * This is a model with one string property 252 + */ 253 + export const zModelWithStringError = z.object({ 254 + prop: z.optional(z.string()) 255 + }); 256 + 257 + /** 258 + * `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) 259 + */ 260 + export const zModelFromZendesk = z.string(); 261 + 262 + /** 263 + * This is a model with one string property 264 + */ 265 + export const zModelWithNullableString = z.object({ 266 + nullableProp1: z.optional(z.union([ 267 + z.string(), 268 + z.null() 269 + ])), 270 + nullableRequiredProp1: z.union([ 271 + z.string(), 272 + z.null() 273 + ]), 274 + nullableProp2: z.optional(z.union([ 275 + z.string(), 276 + z.null() 277 + ])), 278 + nullableRequiredProp2: z.union([ 279 + z.string(), 280 + z.null() 281 + ]), 282 + 'foo_bar-enum': z.optional(z.enum([ 283 + 'Success', 284 + 'Warning', 285 + 'Error', 286 + 'ØÆÅ字符串' 287 + ])) 288 + }); 289 + 290 + /** 291 + * This is a model with one enum 292 + */ 293 + export const zModelWithEnum = z.object({ 294 + 'foo_bar-enum': z.optional(z.enum([ 295 + 'Success', 296 + 'Warning', 297 + 'Error', 298 + 'ØÆÅ字符串' 299 + ])), 300 + statusCode: z.optional(z.enum([ 301 + '100', 302 + '200 FOO', 303 + '300 FOO_BAR', 304 + '400 foo-bar', 305 + '500 foo.bar', 306 + '600 foo&bar' 307 + ])), 308 + bool: z.optional(z.unknown()) 309 + }); 310 + 311 + /** 312 + * This is a model with one enum with escaped name 313 + */ 314 + export const zModelWithEnumWithHyphen = z.object({ 315 + 'foo-bar-baz-qux': z.optional(z.enum([ 316 + '3.0' 317 + ])) 318 + }); 319 + 320 + /** 321 + * This is a model with one enum 322 + */ 323 + export const zModelWithEnumFromDescription = z.object({ 324 + test: z.optional(z.int()) 325 + }); 326 + 327 + /** 328 + * This is a model with nested enums 329 + */ 330 + export const zModelWithNestedEnums = z.object({ 331 + dictionaryWithEnum: z.optional(z.object({})), 332 + dictionaryWithEnumFromDescription: z.optional(z.object({})), 333 + arrayWithEnum: z.optional(z.array(z.enum([ 334 + 'Success', 335 + 'Warning', 336 + 'Error' 337 + ]))), 338 + arrayWithDescription: z.optional(z.array(z.int())), 339 + 'foo_bar-enum': z.optional(z.enum([ 340 + 'Success', 341 + 'Warning', 342 + 'Error', 343 + 'ØÆÅ字符串' 344 + ])) 345 + }); 346 + 347 + /** 348 + * This is a model with one nested property 349 + */ 350 + export const zModelWithProperties = z.object({ 351 + required: z.string(), 352 + requiredAndReadOnly: z.readonly(z.string()), 353 + requiredAndNullable: z.union([ 354 + z.string(), 355 + z.null() 356 + ]), 357 + string: z.optional(z.string()), 358 + number: z.optional(z.number()), 359 + boolean: z.optional(z.boolean()), 360 + reference: z.optional(zModelWithString), 361 + 'property with space': z.optional(z.string()), 362 + default: z.optional(z.string()), 363 + try: z.optional(z.string()), 364 + '@namespace.string': z.optional(z.readonly(z.string())), 365 + '@namespace.integer': z.optional(z.readonly(z.int())) 366 + }); 367 + 368 + /** 369 + * This is a model with one property containing a reference 370 + */ 371 + export const zModelWithReference = z.object({ 372 + prop: z.optional(zModelWithProperties) 373 + }); 374 + 375 + export const zModelWithReadOnlyAndWriteOnly = z.object({ 376 + foo: z.string(), 377 + bar: z.readonly(z.string()) 378 + }); 379 + 380 + /** 381 + * This is a model with one property containing an array 382 + */ 383 + export const zModelWithArrayReadOnlyAndWriteOnly = z.object({ 384 + prop: z.optional(z.array(zModelWithReadOnlyAndWriteOnly)), 385 + propWithFile: z.optional(z.array(z.string())), 386 + propWithNumber: z.optional(z.array(z.number())) 387 + }); 388 + 389 + /** 390 + * This is a model with one property containing an array 391 + */ 392 + export const zModelWithArray = z.object({ 393 + prop: z.optional(z.array(zModelWithString)), 394 + propWithFile: z.optional(z.array(z.string())), 395 + propWithNumber: z.optional(z.array(z.number())) 396 + }); 397 + 398 + /** 399 + * This is a model with one property containing a dictionary 400 + */ 401 + export const zModelWithDictionary = z.object({ 402 + prop: z.optional(z.object({})) 403 + }); 404 + 405 + /** 406 + * This is a deprecated model with a deprecated property 407 + * @deprecated 408 + */ 409 + export const zDeprecatedModel = z.object({ 410 + prop: z.optional(z.string()) 411 + }); 412 + 413 + /** 414 + * This is a model with one property containing a circular reference 415 + */ 416 + export const zModelWithCircularReference = z.object({ 417 + get prop(): z.ZodMiniOptional { 418 + return z.optional(z.lazy((): any => { 419 + return zModelWithCircularReference; 420 + })); 421 + } 422 + }); 423 + 424 + /** 425 + * This is a model with one property with a 'one of' relationship 426 + */ 427 + export const zCompositionWithOneOf = z.object({ 428 + propA: z.optional(z.union([ 429 + zModelWithString, 430 + zModelWithEnum, 431 + zModelWithArray, 432 + zModelWithDictionary 433 + ])) 434 + }); 435 + 436 + /** 437 + * This is a model with one property with a 'one of' relationship where the options are not $ref 438 + */ 439 + export const zCompositionWithOneOfAnonymous = z.object({ 440 + propA: z.optional(z.union([ 441 + z.object({ 442 + propA: z.optional(z.string()) 443 + }), 444 + z.string(), 445 + z.int() 446 + ])) 447 + }); 448 + 449 + /** 450 + * Circle 451 + */ 452 + export const zModelCircle = z.object({ 453 + kind: z.string(), 454 + radius: z.optional(z.number()) 455 + }); 456 + 457 + /** 458 + * Square 459 + */ 460 + export const zModelSquare = z.object({ 461 + kind: z.string(), 462 + sideLength: z.optional(z.number()) 463 + }); 464 + 465 + /** 466 + * This is a model with one property with a 'one of' relationship where the options are not $ref 467 + */ 468 + export const zCompositionWithOneOfDiscriminator = z.union([ 469 + z.intersection(z.object({ 470 + kind: z.literal('circle') 471 + }), zModelCircle), 472 + z.intersection(z.object({ 473 + kind: z.literal('square') 474 + }), zModelSquare) 475 + ]); 476 + 477 + /** 478 + * This is a model with one property with a 'any of' relationship 479 + */ 480 + export const zCompositionWithAnyOf = z.object({ 481 + propA: z.optional(z.union([ 482 + zModelWithString, 483 + zModelWithEnum, 484 + zModelWithArray, 485 + zModelWithDictionary 486 + ])) 487 + }); 488 + 489 + /** 490 + * This is a model with one property with a 'any of' relationship where the options are not $ref 491 + */ 492 + export const zCompositionWithAnyOfAnonymous = z.object({ 493 + propA: z.optional(z.union([ 494 + z.object({ 495 + propA: z.optional(z.string()) 496 + }), 497 + z.string(), 498 + z.int() 499 + ])) 500 + }); 501 + 502 + /** 503 + * This is a model with nested 'any of' property with a type null 504 + */ 505 + export const zCompositionWithNestedAnyAndTypeNull = z.object({ 506 + propA: z.optional(z.union([ 507 + z.array(z.union([ 508 + zModelWithDictionary, 509 + z.null() 510 + ])), 511 + z.array(z.union([ 512 + zModelWithArray, 513 + z.null() 514 + ])) 515 + ])) 516 + }); 517 + 518 + export const z3eNum1Период = z.enum([ 519 + 'Bird', 520 + 'Dog' 521 + ]); 522 + 523 + export const zConstValue = z.literal('ConstValue'); 524 + 525 + /** 526 + * This is a model with one property with a 'any of' relationship where the options are not $ref 527 + */ 528 + export const zCompositionWithNestedAnyOfAndNull = z.object({ 529 + propA: z.optional(z.union([ 530 + z.array(z.union([ 531 + z3eNum1Период, 532 + zConstValue 533 + ])), 534 + z.null() 535 + ])) 536 + }); 537 + 538 + /** 539 + * This is a model with one property with a 'one of' relationship 540 + */ 541 + export const zCompositionWithOneOfAndNullable = z.object({ 542 + propA: z.optional(z.union([ 543 + z.object({ 544 + boolean: z.optional(z.boolean()) 545 + }), 546 + zModelWithEnum, 547 + zModelWithArray, 548 + zModelWithDictionary, 549 + z.null() 550 + ])) 551 + }); 552 + 553 + /** 554 + * This is a model that contains a simple dictionary within composition 555 + */ 556 + export const zCompositionWithOneOfAndSimpleDictionary = z.object({ 557 + propA: z.optional(z.union([ 558 + z.boolean(), 559 + z.object({}) 560 + ])) 561 + }); 562 + 563 + /** 564 + * This is a model that contains a dictionary of simple arrays within composition 565 + */ 566 + export const zCompositionWithOneOfAndSimpleArrayDictionary = z.object({ 567 + propA: z.optional(z.union([ 568 + z.boolean(), 569 + z.object({}) 570 + ])) 571 + }); 572 + 573 + /** 574 + * This is a model that contains a dictionary of complex arrays (composited) within composition 575 + */ 576 + export const zCompositionWithOneOfAndComplexArrayDictionary = z.object({ 577 + propA: z.optional(z.union([ 578 + z.boolean(), 579 + z.object({}) 580 + ])) 581 + }); 582 + 583 + /** 584 + * This is a model with one property with a 'all of' relationship 585 + */ 586 + export const zCompositionWithAllOfAndNullable = z.object({ 587 + propA: z.optional(z.union([ 588 + z.intersection(z.intersection(z.intersection(z.object({ 589 + boolean: z.optional(z.boolean()) 590 + }), zModelWithEnum), zModelWithArray), zModelWithDictionary), 591 + z.null() 592 + ])) 593 + }); 594 + 595 + /** 596 + * This is a model with one property with a 'any of' relationship 597 + */ 598 + export const zCompositionWithAnyOfAndNullable = z.object({ 599 + propA: z.optional(z.union([ 600 + z.object({ 601 + boolean: z.optional(z.boolean()) 602 + }), 603 + zModelWithEnum, 604 + zModelWithArray, 605 + zModelWithDictionary, 606 + z.null() 607 + ])) 608 + }); 609 + 610 + /** 611 + * This is a base model with two simple optional properties 612 + */ 613 + export const zCompositionBaseModel = z.object({ 614 + firstName: z.optional(z.string()), 615 + lastname: z.optional(z.string()) 616 + }); 617 + 618 + /** 619 + * This is a model that extends the base model 620 + */ 621 + export const zCompositionExtendedModel = z.intersection(zCompositionBaseModel, z.object({ 622 + age: z.number(), 623 + firstName: z.string(), 624 + lastname: z.string() 625 + })); 626 + 627 + /** 628 + * This is a model with one nested property 629 + */ 630 + export const zModelWithNestedProperties = z.object({ 631 + first: z.readonly(z.union([ 632 + z.readonly(z.object({ 633 + second: z.readonly(z.union([ 634 + z.readonly(z.object({ 635 + third: z.readonly(z.union([ 636 + z.readonly(z.string()), 637 + z.null() 638 + ])) 639 + })), 640 + z.null() 641 + ])) 642 + })), 643 + z.null() 644 + ])) 645 + }); 646 + 647 + /** 648 + * This is a model with duplicated properties 649 + */ 650 + export const zModelWithDuplicateProperties = z.object({ 651 + prop: z.optional(zModelWithString) 652 + }); 653 + 654 + /** 655 + * This is a model with ordered properties 656 + */ 657 + export const zModelWithOrderedProperties = z.object({ 658 + zebra: z.optional(z.string()), 659 + apple: z.optional(z.string()), 660 + hawaii: z.optional(z.string()) 661 + }); 662 + 663 + /** 664 + * This is a model with duplicated imports 665 + */ 666 + export const zModelWithDuplicateImports = z.object({ 667 + propA: z.optional(zModelWithString), 668 + propB: z.optional(zModelWithString), 669 + propC: z.optional(zModelWithString) 670 + }); 671 + 672 + /** 673 + * This is a model that extends another model 674 + */ 675 + export const zModelThatExtends = z.intersection(zModelWithString, z.object({ 676 + propExtendsA: z.optional(z.string()), 677 + propExtendsB: z.optional(zModelWithString) 678 + })); 679 + 680 + /** 681 + * This is a model that extends another model 682 + */ 683 + export const zModelThatExtendsExtends = z.intersection(z.intersection(zModelWithString, zModelThatExtends), z.object({ 684 + propExtendsC: z.optional(z.string()), 685 + propExtendsD: z.optional(zModelWithString) 686 + })); 687 + 688 + /** 689 + * This is a model that contains a some patterns 690 + */ 691 + export const zModelWithPattern = z.object({ 692 + key: z.string().check(z.maxLength(64), z.regex(/^[a-zA-Z0-9_]*$/)), 693 + name: z.string().check(z.maxLength(255)), 694 + enabled: z.optional(z.readonly(z.boolean())), 695 + modified: z.optional(z.readonly(z.iso.datetime())), 696 + id: z.optional(z.string().check(z.regex(/^\d{2}-\d{3}-\d{4}$/))), 697 + text: z.optional(z.string().check(z.regex(/^\w+$/))), 698 + patternWithSingleQuotes: z.optional(z.string().check(z.regex(/^[a-zA-Z0-9']*$/))), 699 + patternWithNewline: z.optional(z.string().check(z.regex(/aaa\nbbb/))), 700 + patternWithBacktick: z.optional(z.string().check(z.regex(/aaa`bbb/))) 701 + }); 702 + 703 + export const zFile = z.object({ 704 + id: z.optional(z.readonly(z.string().check(z.minLength(1)))), 705 + updated_at: z.optional(z.readonly(z.iso.datetime())), 706 + created_at: z.optional(z.readonly(z.iso.datetime())), 707 + mime: z.string().check(z.minLength(1), z.maxLength(24)), 708 + file: z.optional(z.readonly(z.url())) 709 + }); 710 + 711 + export const zDefault = z.object({ 712 + name: z.optional(z.string()) 713 + }); 714 + 715 + export const zPageable = z.object({ 716 + page: z._default(z.optional(z.int().check(z.gte(0))), 0), 717 + size: z.optional(z.int().check(z.gte(1))), 718 + sort: z.optional(z.array(z.string())) 719 + }); 720 + 721 + /** 722 + * This is a free-form object without additionalProperties. 723 + */ 724 + export const zFreeFormObjectWithoutAdditionalProperties = z.object({}); 725 + 726 + /** 727 + * This is a free-form object with additionalProperties: true. 728 + */ 729 + export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.object({}); 730 + 731 + /** 732 + * This is a free-form object with additionalProperties: {}. 733 + */ 734 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.object({}); 735 + 736 + export const zModelWithConst = z.object({ 737 + String: z.optional(z.literal('String')), 738 + number: z.optional(z.literal(0)), 739 + null: z.optional(z.null()), 740 + withType: z.optional(z.literal('Some string')) 741 + }); 742 + 743 + /** 744 + * This is a model with one property and additionalProperties: true 745 + */ 746 + export const zModelWithAdditionalPropertiesEqTrue = z.object({ 747 + prop: z.optional(z.string()) 748 + }); 749 + 750 + export const zNestedAnyOfArraysNullable = z.object({ 751 + nullableArray: z.optional(z.union([ 752 + z.array(z.union([ 753 + z.string(), 754 + z.boolean() 755 + ])), 756 + z.null() 757 + ])) 758 + }); 759 + 760 + /** 761 + * This is a reusable parameter 762 + */ 763 + export const zSimpleParameter = z.unknown(); 764 + 765 + export const zCompositionWithOneOfAndProperties = z.intersection(z.union([ 766 + z.object({ 767 + foo: zSimpleParameter 768 + }), 769 + z.object({ 770 + bar: zNonAsciiStringæøåÆøÅöôêÊ字符串 771 + }) 772 + ]), z.object({ 773 + baz: z.union([ 774 + z.int().check(z.gte(0)), 775 + z.null() 776 + ]), 777 + qux: z.int().check(z.gte(0)) 778 + })); 779 + 780 + /** 781 + * An object that can be null 782 + */ 783 + export const zNullableObject = z._default(z.union([ 784 + z.object({ 785 + foo: z.optional(z.string()) 786 + }), 787 + z.null() 788 + ]), null); 789 + 790 + /** 791 + * Some % character 792 + */ 793 + export const zCharactersInDescription = z.string(); 794 + 795 + export const zModelWithNullableObject = z.object({ 796 + data: z.optional(zNullableObject) 797 + }); 798 + 799 + export const zModelWithOneOfEnum = z.union([ 800 + z.object({ 801 + foo: z.enum([ 802 + 'Bar' 803 + ]) 804 + }), 805 + z.object({ 806 + foo: z.enum([ 807 + 'Baz' 808 + ]) 809 + }), 810 + z.object({ 811 + foo: z.enum([ 812 + 'Qux' 813 + ]) 814 + }), 815 + z.object({ 816 + content: z.iso.datetime(), 817 + foo: z.enum([ 818 + 'Quux' 819 + ]) 820 + }), 821 + z.object({ 822 + content: z.tuple([ 823 + z.iso.datetime(), 824 + z.string() 825 + ]), 826 + foo: z.enum([ 827 + 'Corge' 828 + ]) 829 + }) 830 + ]); 831 + 832 + export const zModelWithNestedArrayEnumsDataFoo = z.enum([ 833 + 'foo', 834 + 'bar' 835 + ]); 836 + 837 + export const zModelWithNestedArrayEnumsDataBar = z.enum([ 838 + 'baz', 839 + 'qux' 840 + ]); 841 + 842 + export const zModelWithNestedArrayEnumsData = z.object({ 843 + foo: z.optional(z.array(zModelWithNestedArrayEnumsDataFoo)), 844 + bar: z.optional(z.array(zModelWithNestedArrayEnumsDataBar)) 845 + }); 846 + 847 + export const zModelWithNestedArrayEnums = z.object({ 848 + array_strings: z.optional(z.array(z.string())), 849 + data: z.optional(zModelWithNestedArrayEnumsData) 850 + }); 851 + 852 + export const zModelWithNestedCompositionEnums = z.object({ 853 + foo: z.optional(zModelWithNestedArrayEnumsDataFoo) 854 + }); 855 + 856 + export const zModelWithConstantSizeArray = z.tuple([ 857 + z.number(), 858 + z.number() 859 + ]); 860 + 861 + export const zModelWithAnyOfConstantSizeArray = z.tuple([ 862 + z.union([ 863 + z.number(), 864 + z.string() 865 + ]), 866 + z.union([ 867 + z.number(), 868 + z.string() 869 + ]), 870 + z.union([ 871 + z.number(), 872 + z.string() 873 + ]) 874 + ]); 875 + 876 + export const zModelWithPrefixItemsConstantSizeArray = z.tuple([ 877 + zModelWithInteger, 878 + z.union([ 879 + z.number(), 880 + z.string() 881 + ]), 882 + z.string() 883 + ]); 884 + 885 + export const zModelWithAnyOfConstantSizeArrayNullable = z.tuple([ 886 + z.union([ 887 + z.number(), 888 + z.null(), 889 + z.string() 890 + ]), 891 + z.union([ 892 + z.number(), 893 + z.null(), 894 + z.string() 895 + ]), 896 + z.union([ 897 + z.number(), 898 + z.null(), 899 + z.string() 900 + ]) 901 + ]); 902 + 903 + /** 904 + * Model with restricted keyword name 905 + */ 906 + export const zImport = z.string(); 907 + 908 + export const zModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = z.tuple([ 909 + z.union([ 910 + z.number(), 911 + zImport 912 + ]), 913 + z.union([ 914 + z.number(), 915 + zImport 916 + ]) 917 + ]); 918 + 919 + export const zModelWithAnyOfConstantSizeArrayAndIntersect = z.tuple([ 920 + z.intersection(z.number(), z.string()), 921 + z.intersection(z.number(), z.string()) 922 + ]); 923 + 924 + export const zModelWithNumericEnumUnion = z.object({ 925 + value: z.optional(z.unknown()) 926 + }); 927 + 928 + /** 929 + * Some description with `back ticks` 930 + */ 931 + export const zModelWithBackticksInDescription = z.object({ 932 + template: z.optional(z.string()) 933 + }); 934 + 935 + export const zModelWithOneOfAndProperties = z.intersection(z.union([ 936 + zSimpleParameter, 937 + zNonAsciiStringæøåÆøÅöôêÊ字符串 938 + ]), z.object({ 939 + baz: z.union([ 940 + z.int().check(z.gte(0)), 941 + z.null() 942 + ]), 943 + qux: z.int().check(z.gte(0)) 944 + })); 945 + 946 + /** 947 + * Model used to test deduplication strategy (unused) 948 + */ 949 + export const zParameterSimpleParameterUnused = z.string(); 950 + 951 + /** 952 + * Model used to test deduplication strategy 953 + */ 954 + export const zPostServiceWithEmptyTagResponse = z.string(); 955 + 956 + /** 957 + * Model used to test deduplication strategy 958 + */ 959 + export const zPostServiceWithEmptyTagResponse2 = z.string(); 960 + 961 + /** 962 + * Model used to test deduplication strategy 963 + */ 964 + export const zDeleteFooData = z.string(); 965 + 966 + /** 967 + * Model used to test deduplication strategy 968 + */ 969 + export const zDeleteFooData2 = z.string(); 970 + 971 + export const zSchemaWithFormRestrictedKeys = z.object({ 972 + description: z.optional(z.string()), 973 + 'x-enum-descriptions': z.optional(z.string()), 974 + 'x-enum-varnames': z.optional(z.string()), 975 + 'x-enumNames': z.optional(z.string()), 976 + title: z.optional(z.string()), 977 + object: z.optional(z.object({ 978 + description: z.optional(z.string()), 979 + 'x-enum-descriptions': z.optional(z.string()), 980 + 'x-enum-varnames': z.optional(z.string()), 981 + 'x-enumNames': z.optional(z.string()), 982 + title: z.optional(z.string()) 983 + })), 984 + array: z.optional(z.array(z.object({ 985 + description: z.optional(z.string()), 986 + 'x-enum-descriptions': z.optional(z.string()), 987 + 'x-enum-varnames': z.optional(z.string()), 988 + 'x-enumNames': z.optional(z.string()), 989 + title: z.optional(z.string()) 990 + }))) 991 + }); 992 + 993 + /** 994 + * This schema was giving PascalCase transformations a hard time 995 + */ 996 + export const zIoK8sApimachineryPkgApisMetaV1Preconditions = z.object({ 997 + resourceVersion: z.optional(z.string()), 998 + uid: z.optional(z.string()) 999 + }); 1000 + 1001 + /** 1002 + * This schema was giving PascalCase transformations a hard time 1003 + */ 1004 + export const zIoK8sApimachineryPkgApisMetaV1DeleteOptions = z.object({ 1005 + preconditions: z.optional(zIoK8sApimachineryPkgApisMetaV1Preconditions) 1006 + }); 1007 + 1008 + export const zAdditionalPropertiesUnknownIssue = z.object({}); 1009 + 1010 + export const zAdditionalPropertiesUnknownIssue2 = z.object({}); 1011 + 1012 + export const zAdditionalPropertiesUnknownIssue3 = z.intersection(z.string(), z.object({ 1013 + entries: z.object({}) 1014 + })); 1015 + 1016 + export const zAdditionalPropertiesIntegerIssue = z.object({ 1017 + value: z.int() 1018 + }); 1019 + 1020 + export const zGenericSchemaDuplicateIssue1SystemBoolean = z.object({ 1021 + item: z.optional(z.boolean()), 1022 + error: z.optional(z.union([ 1023 + z.string(), 1024 + z.null() 1025 + ])), 1026 + hasError: z.optional(z.readonly(z.boolean())), 1027 + data: z.optional(z.object({})) 1028 + }); 1029 + 1030 + export const zGenericSchemaDuplicateIssue1SystemString = z.object({ 1031 + item: z.optional(z.union([ 1032 + z.string(), 1033 + z.null() 1034 + ])), 1035 + error: z.optional(z.union([ 1036 + z.string(), 1037 + z.null() 1038 + ])), 1039 + hasError: z.optional(z.readonly(z.boolean())) 1040 + }); 1041 + 1042 + export const zOneOfAllOfIssue = z.union([ 1043 + z.intersection(z.union([ 1044 + zConstValue, 1045 + zGenericSchemaDuplicateIssue1SystemBoolean 1046 + ]), z3eNum1Период), 1047 + zGenericSchemaDuplicateIssue1SystemString 1048 + ]); 1049 + 1050 + /** 1051 + * Model with number-only name 1052 + */ 1053 + export const z400Writable = z.string(); 1054 + 1055 + /** 1056 + * Testing multiline comments in string: First line 1057 + * Second line 1058 + * 1059 + * Fourth line 1060 + */ 1061 + export const zCamelCaseCommentWithBreaksWritable = z.int(); 1062 + 1063 + /** 1064 + * Testing multiline comments in string: First line 1065 + * Second line 1066 + * 1067 + * Fourth line 1068 + */ 1069 + export const zCommentWithBreaksWritable = z.int(); 1070 + 1071 + /** 1072 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 1073 + */ 1074 + export const zCommentWithBackticksWritable = z.int(); 1075 + 1076 + /** 1077 + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 1078 + */ 1079 + export const zCommentWithBackticksAndQuotesWritable = z.int(); 1080 + 1081 + /** 1082 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 1083 + */ 1084 + export const zCommentWithSlashesWritable = z.int(); 1085 + 1086 + /** 1087 + * Testing expression placeholders in string: ${expression} should work 1088 + */ 1089 + export const zCommentWithExpressionPlaceholdersWritable = z.int(); 1090 + 1091 + /** 1092 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 1093 + */ 1094 + export const zCommentWithQuotesWritable = z.int(); 1095 + 1096 + /** 1097 + * Testing reserved characters in string: * inline * and ** inline ** should work 1098 + */ 1099 + export const zCommentWithReservedCharactersWritable = z.int(); 1100 + 1101 + /** 1102 + * This is a simple number 1103 + */ 1104 + export const zSimpleIntegerWritable = z.int(); 1105 + 1106 + /** 1107 + * This is a simple boolean 1108 + */ 1109 + export const zSimpleBooleanWritable = z.boolean(); 1110 + 1111 + /** 1112 + * This is a simple string 1113 + */ 1114 + export const zSimpleStringWritable = z.string(); 1115 + 1116 + /** 1117 + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 1118 + */ 1119 + export const zNonAsciiStringæøåÆøÅöôêÊ字符串Writable = z.string(); 1120 + 1121 + /** 1122 + * This is a simple file 1123 + */ 1124 + export const zSimpleFileWritable = z.string(); 1125 + 1126 + /** 1127 + * This is a simple string 1128 + */ 1129 + export const zSimpleStringWithPatternWritable = z.union([ 1130 + z.string().check(z.maxLength(64), z.regex(/^[a-zA-Z0-9_]*$/)), 1131 + z.null() 1132 + ]); 1133 + 1134 + /** 1135 + * This is a simple enum with strings 1136 + */ 1137 + export const zEnumWithStringsWritable = z.enum([ 1138 + 'Success', 1139 + 'Warning', 1140 + 'Error', 1141 + "'Single Quote'", 1142 + '"Double Quotes"', 1143 + 'Non-ascii: øæåôöØÆÅÔÖ字符串' 1144 + ]); 1145 + 1146 + export const zEnumWithReplacedCharactersWritable = z.enum([ 1147 + "'Single Quote'", 1148 + '"Double Quotes"', 1149 + 'øæåôöØÆÅÔÖ字符串', 1150 + '' 1151 + ]); 1152 + 1153 + /** 1154 + * This is a simple enum with numbers 1155 + */ 1156 + export const zEnumWithNumbersWritable = z.unknown(); 1157 + 1158 + /** 1159 + * Success=1,Warning=2,Error=3 1160 + */ 1161 + export const zEnumFromDescriptionWritable = z.number(); 1162 + 1163 + /** 1164 + * This is a simple enum with numbers 1165 + */ 1166 + export const zEnumWithExtensionsWritable = z.unknown(); 1167 + 1168 + export const zEnumWithXEnumNamesWritable = z.unknown(); 1169 + 1170 + /** 1171 + * This is a simple array with numbers 1172 + */ 1173 + export const zArrayWithNumbersWritable = z.array(z.int()); 1174 + 1175 + /** 1176 + * This is a simple array with booleans 1177 + */ 1178 + export const zArrayWithBooleansWritable = z.array(z.boolean()); 1179 + 1180 + /** 1181 + * This is a simple array with strings 1182 + */ 1183 + export const zArrayWithStringsWritable = z._default(z.array(z.string()), ['test']); 1184 + 1185 + /** 1186 + * This is a string dictionary 1187 + */ 1188 + export const zDictionaryWithStringWritable = z.object({}); 1189 + 1190 + /** 1191 + * This is a string dictionary 1192 + */ 1193 + export const zDictionaryWithDictionaryWritable = z.record(z.string(), z.object({})); 1194 + 1195 + /** 1196 + * `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) 1197 + */ 1198 + export const zModelFromZendeskWritable = z.string(); 1199 + 1200 + export const zModelWithReadOnlyAndWriteOnlyWritable = z.object({ 1201 + foo: z.string(), 1202 + baz: z.string() 1203 + }); 1204 + 1205 + /** 1206 + * This is a model with one property containing an array 1207 + */ 1208 + export const zModelWithArrayReadOnlyAndWriteOnlyWritable = z.object({ 1209 + prop: z.optional(z.array(zModelWithReadOnlyAndWriteOnlyWritable)), 1210 + propWithFile: z.optional(z.array(z.string())), 1211 + propWithNumber: z.optional(z.array(z.number())) 1212 + }); 1213 + 1214 + export const z3eNum1ПериодWritable = z.enum([ 1215 + 'Bird', 1216 + 'Dog' 1217 + ]); 1218 + 1219 + export const zConstValueWritable = z.literal('ConstValue'); 1220 + 1221 + /** 1222 + * This is a free-form object without additionalProperties. 1223 + */ 1224 + export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.object({}); 1225 + 1226 + /** 1227 + * This is a free-form object with additionalProperties: true. 1228 + */ 1229 + export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.object({}); 1230 + 1231 + /** 1232 + * This is a free-form object with additionalProperties: {}. 1233 + */ 1234 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.object({}); 1235 + 1236 + /** 1237 + * Some % character 1238 + */ 1239 + export const zCharactersInDescriptionWritable = z.string(); 1240 + 1241 + export const zModelWithNestedArrayEnumsDataFooWritable = z.enum([ 1242 + 'foo', 1243 + 'bar' 1244 + ]); 1245 + 1246 + export const zModelWithNestedArrayEnumsDataBarWritable = z.enum([ 1247 + 'baz', 1248 + 'qux' 1249 + ]); 1250 + 1251 + export const zModelWithConstantSizeArrayWritable = z.tuple([ 1252 + z.number(), 1253 + z.number() 1254 + ]); 1255 + 1256 + export const zModelWithAnyOfConstantSizeArrayWritable = z.tuple([ 1257 + z.union([ 1258 + z.number(), 1259 + z.string() 1260 + ]), 1261 + z.union([ 1262 + z.number(), 1263 + z.string() 1264 + ]), 1265 + z.union([ 1266 + z.number(), 1267 + z.string() 1268 + ]) 1269 + ]); 1270 + 1271 + export const zModelWithAnyOfConstantSizeArrayNullableWritable = z.tuple([ 1272 + z.union([ 1273 + z.number(), 1274 + z.null(), 1275 + z.string() 1276 + ]), 1277 + z.union([ 1278 + z.number(), 1279 + z.null(), 1280 + z.string() 1281 + ]), 1282 + z.union([ 1283 + z.number(), 1284 + z.null(), 1285 + z.string() 1286 + ]) 1287 + ]); 1288 + 1289 + /** 1290 + * Model with restricted keyword name 1291 + */ 1292 + export const zImportWritable = z.string(); 1293 + 1294 + export const zModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = z.tuple([ 1295 + z.union([ 1296 + z.number(), 1297 + zImportWritable 1298 + ]), 1299 + z.union([ 1300 + z.number(), 1301 + zImportWritable 1302 + ]) 1303 + ]); 1304 + 1305 + export const zModelWithAnyOfConstantSizeArrayAndIntersectWritable = z.tuple([ 1306 + z.intersection(z.number(), z.string()), 1307 + z.intersection(z.number(), z.string()) 1308 + ]); 1309 + 1310 + /** 1311 + * Model used to test deduplication strategy (unused) 1312 + */ 1313 + export const zParameterSimpleParameterUnusedWritable = z.string(); 1314 + 1315 + /** 1316 + * Model used to test deduplication strategy 1317 + */ 1318 + export const zPostServiceWithEmptyTagResponseWritable = z.string(); 1319 + 1320 + /** 1321 + * Model used to test deduplication strategy 1322 + */ 1323 + export const zPostServiceWithEmptyTagResponse2Writable = z.string(); 1324 + 1325 + /** 1326 + * Model used to test deduplication strategy 1327 + */ 1328 + export const zDeleteFooDataWritable = z.string(); 1329 + 1330 + /** 1331 + * Model used to test deduplication strategy 1332 + */ 1333 + export const zDeleteFooData2Writable = z.string(); 1334 + 1335 + export const zAdditionalPropertiesUnknownIssueWritable = z.object({}); 1336 + 1337 + export const zAdditionalPropertiesUnknownIssue2Writable = z.object({}); 1338 + 1339 + export const zOneOfAllOfIssueWritable = z.union([ 1340 + z.intersection(z.union([ 1341 + zConstValueWritable, 1342 + zGenericSchemaDuplicateIssue1SystemBoolean 1343 + ]), z3eNum1Период), 1344 + zGenericSchemaDuplicateIssue1SystemString 1345 + ]); 1346 + 1347 + /** 1348 + * Parameter with illegal characters 1349 + */ 1350 + export const zXFooBar = zModelWithString; 1351 + 1352 + /** 1353 + * A reusable request body 1354 + */ 1355 + export const zSimpleRequestBody = zModelWithString; 1356 + 1357 + /** 1358 + * A reusable request body 1359 + */ 1360 + export const zSimpleFormData = zModelWithString; 1361 + 1362 + export const zExportData = z.object({ 1363 + body: z.optional(z.never()), 1364 + path: z.optional(z.never()), 1365 + query: z.optional(z.never()) 1366 + }); 1367 + 1368 + export const zPatchApiVbyApiVersionNoTagData = z.object({ 1369 + body: z.optional(z.never()), 1370 + path: z.optional(z.never()), 1371 + query: z.optional(z.never()) 1372 + }); 1373 + 1374 + export const zImportData = z.object({ 1375 + body: z.union([ 1376 + zModelWithReadOnlyAndWriteOnlyWritable, 1377 + zModelWithArrayReadOnlyAndWriteOnlyWritable 1378 + ]), 1379 + path: z.optional(z.never()), 1380 + query: z.optional(z.never()) 1381 + }); 1382 + 1383 + export const zImportResponse = z.union([ 1384 + zModelFromZendesk, 1385 + zModelWithReadOnlyAndWriteOnly 1386 + ]); 1387 + 1388 + export const zFooWowData = z.object({ 1389 + body: z.optional(z.never()), 1390 + path: z.optional(z.never()), 1391 + query: z.optional(z.never()) 1392 + }); 1393 + 1394 + export const zApiVVersionODataControllerCountData = z.object({ 1395 + body: z.optional(z.never()), 1396 + path: z.optional(z.never()), 1397 + query: z.optional(z.never()) 1398 + }); 1399 + 1400 + /** 1401 + * Success 1402 + */ 1403 + export const zApiVVersionODataControllerCountResponse = zModelFromZendesk; 1404 + 1405 + export const zGetApiVbyApiVersionSimpleOperationData = z.object({ 1406 + body: z.optional(z.never()), 1407 + path: z.object({ 1408 + foo_param: z.union([ 1409 + z.string(), 1410 + z.uuid() 1411 + ]) 1412 + }), 1413 + query: z.optional(z.never()) 1414 + }); 1415 + 1416 + /** 1417 + * Response is a simple number 1418 + */ 1419 + export const zGetApiVbyApiVersionSimpleOperationResponse = z.number(); 1420 + 1421 + export const zDeleteCallWithoutParametersAndResponseData = z.object({ 1422 + body: z.optional(z.never()), 1423 + path: z.optional(z.never()), 1424 + query: z.optional(z.never()) 1425 + }); 1426 + 1427 + export const zGetCallWithoutParametersAndResponseData = z.object({ 1428 + body: z.optional(z.never()), 1429 + path: z.optional(z.never()), 1430 + query: z.optional(z.never()) 1431 + }); 1432 + 1433 + export const zHeadCallWithoutParametersAndResponseData = z.object({ 1434 + body: z.optional(z.never()), 1435 + path: z.optional(z.never()), 1436 + query: z.optional(z.never()) 1437 + }); 1438 + 1439 + export const zOptionsCallWithoutParametersAndResponseData = z.object({ 1440 + body: z.optional(z.never()), 1441 + path: z.optional(z.never()), 1442 + query: z.optional(z.never()) 1443 + }); 1444 + 1445 + export const zPatchCallWithoutParametersAndResponseData = z.object({ 1446 + body: z.optional(z.never()), 1447 + path: z.optional(z.never()), 1448 + query: z.optional(z.never()) 1449 + }); 1450 + 1451 + export const zPostCallWithoutParametersAndResponseData = z.object({ 1452 + body: z.optional(z.never()), 1453 + path: z.optional(z.never()), 1454 + query: z.optional(z.never()) 1455 + }); 1456 + 1457 + export const zPutCallWithoutParametersAndResponseData = z.object({ 1458 + body: z.optional(z.never()), 1459 + path: z.optional(z.never()), 1460 + query: z.optional(z.never()) 1461 + }); 1462 + 1463 + export const zDeleteFooData3 = z.object({ 1464 + body: z.optional(z.never()), 1465 + path: z.object({ 1466 + foo_param: z.string(), 1467 + BarParam: z.string() 1468 + }), 1469 + query: z.optional(z.never()), 1470 + headers: z.object({ 1471 + 'x-Foo-Bar': zModelWithString 1472 + }) 1473 + }); 1474 + 1475 + export const zCallWithDescriptionsData = z.object({ 1476 + body: z.optional(z.never()), 1477 + path: z.optional(z.never()), 1478 + query: z.optional(z.object({ 1479 + parameterWithBreaks: z.optional(z.string()), 1480 + parameterWithBackticks: z.optional(z.string()), 1481 + parameterWithSlashes: z.optional(z.string()), 1482 + parameterWithExpressionPlaceholders: z.optional(z.string()), 1483 + parameterWithQuotes: z.optional(z.string()), 1484 + parameterWithReservedCharacters: z.optional(z.string()) 1485 + })) 1486 + }); 1487 + 1488 + export const zDeprecatedCallData = z.object({ 1489 + body: z.optional(z.never()), 1490 + path: z.optional(z.never()), 1491 + query: z.optional(z.never()), 1492 + headers: z.object({ 1493 + parameter: z.union([ 1494 + zDeprecatedModel, 1495 + z.null() 1496 + ]) 1497 + }) 1498 + }); 1499 + 1500 + export const zCallWithParametersData = z.object({ 1501 + body: z.union([ 1502 + z.object({}), 1503 + z.null() 1504 + ]), 1505 + path: z.object({ 1506 + parameterPath: z.union([ 1507 + z.string(), 1508 + z.null() 1509 + ]), 1510 + 'api-version': z.union([ 1511 + z.string(), 1512 + z.null() 1513 + ]) 1514 + }), 1515 + query: z.object({ 1516 + foo_ref_enum: z.optional(zModelWithNestedArrayEnumsDataFooWritable), 1517 + foo_all_of_enum: zModelWithNestedArrayEnumsDataFooWritable, 1518 + cursor: z.union([ 1519 + z.string(), 1520 + z.null() 1521 + ]) 1522 + }), 1523 + headers: z.object({ 1524 + parameterHeader: z.union([ 1525 + z.string(), 1526 + z.null() 1527 + ]) 1528 + }) 1529 + }); 1530 + 1531 + export const zCallWithWeirdParameterNamesData = z.object({ 1532 + body: z.union([ 1533 + zModelWithString, 1534 + z.null() 1535 + ]), 1536 + path: z.object({ 1537 + 'parameter.path.1': z.optional(z.string()), 1538 + 'parameter-path-2': z.optional(z.string()), 1539 + 'PARAMETER-PATH-3': z.optional(z.string()), 1540 + 'api-version': z.union([ 1541 + z.string(), 1542 + z.null() 1543 + ]) 1544 + }), 1545 + query: z.object({ 1546 + default: z.optional(z.string()), 1547 + 'parameter-query': z.union([ 1548 + z.string(), 1549 + z.null() 1550 + ]) 1551 + }), 1552 + headers: z.object({ 1553 + 'parameter.header': z.union([ 1554 + z.string(), 1555 + z.null() 1556 + ]) 1557 + }) 1558 + }); 1559 + 1560 + export const zGetCallWithOptionalParamData = z.object({ 1561 + body: zModelWithOneOfEnum, 1562 + path: z.optional(z.never()), 1563 + query: z.optional(z.object({ 1564 + page: z.optional(z.number()) 1565 + })) 1566 + }); 1567 + 1568 + export const zPostCallWithOptionalParamData = z.object({ 1569 + body: z.optional(z.object({ 1570 + offset: z.optional(z.union([ 1571 + z.number(), 1572 + z.null() 1573 + ])) 1574 + })), 1575 + path: z.optional(z.never()), 1576 + query: z.object({ 1577 + parameter: zPageable 1578 + }) 1579 + }); 1580 + 1581 + export const zPostCallWithOptionalParamResponse = z.union([ 1582 + z.number(), 1583 + z.void() 1584 + ]); 1585 + 1586 + export const zPostApiVbyApiVersionRequestBodyData = z.object({ 1587 + body: z.optional(zSimpleRequestBody), 1588 + path: z.optional(z.never()), 1589 + query: z.optional(z.object({ 1590 + parameter: z.optional(z.string()) 1591 + })) 1592 + }); 1593 + 1594 + export const zPostApiVbyApiVersionFormDataData = z.object({ 1595 + body: z.optional(zSimpleFormData), 1596 + path: z.optional(z.never()), 1597 + query: z.optional(z.object({ 1598 + parameter: z.optional(z.string()) 1599 + })) 1600 + }); 1601 + 1602 + export const zCallWithDefaultParametersData = z.object({ 1603 + body: z.optional(z.never()), 1604 + path: z.optional(z.never()), 1605 + query: z.optional(z.object({ 1606 + parameterString: z._default(z.optional(z.union([ 1607 + z._default(z.string(), 'Hello World!'), 1608 + z.null() 1609 + ])), 'Hello World!'), 1610 + parameterNumber: z._default(z.optional(z.union([ 1611 + z._default(z.number(), 123), 1612 + z.null() 1613 + ])), 123), 1614 + parameterBoolean: z._default(z.optional(z.union([ 1615 + z._default(z.boolean(), true), 1616 + z.null() 1617 + ])), true), 1618 + parameterEnum: z.optional(z.enum([ 1619 + 'Success', 1620 + 'Warning', 1621 + 'Error' 1622 + ])), 1623 + parameterModel: z.optional(z.union([ 1624 + zModelWithString, 1625 + z.null() 1626 + ])) 1627 + })) 1628 + }); 1629 + 1630 + export const zCallWithDefaultOptionalParametersData = z.object({ 1631 + body: z.optional(z.never()), 1632 + path: z.optional(z.never()), 1633 + query: z.optional(z.object({ 1634 + parameterString: z._default(z.optional(z.string()), 'Hello World!'), 1635 + parameterNumber: z._default(z.optional(z.number()), 123), 1636 + parameterBoolean: z._default(z.optional(z.boolean()), true), 1637 + parameterEnum: z.optional(z.enum([ 1638 + 'Success', 1639 + 'Warning', 1640 + 'Error' 1641 + ])), 1642 + parameterModel: z.optional(zModelWithString) 1643 + })) 1644 + }); 1645 + 1646 + export const zCallToTestOrderOfParamsData = z.object({ 1647 + body: z.optional(z.never()), 1648 + path: z.optional(z.never()), 1649 + query: z.object({ 1650 + parameterOptionalStringWithDefault: z._default(z.optional(z.string()), 'Hello World!'), 1651 + parameterOptionalStringWithEmptyDefault: z._default(z.optional(z.string()), ''), 1652 + parameterOptionalStringWithNoDefault: z.optional(z.string()), 1653 + parameterStringWithDefault: z._default(z.string(), 'Hello World!'), 1654 + parameterStringWithEmptyDefault: z._default(z.string(), ''), 1655 + parameterStringWithNoDefault: z.string(), 1656 + parameterStringNullableWithNoDefault: z.optional(z.union([ 1657 + z.string(), 1658 + z.null() 1659 + ])), 1660 + parameterStringNullableWithDefault: z._default(z.optional(z.union([ 1661 + z.string(), 1662 + z.null() 1663 + ])), null) 1664 + }) 1665 + }); 1666 + 1667 + export const zDuplicateNameData = z.object({ 1668 + body: z.optional(z.never()), 1669 + path: z.optional(z.never()), 1670 + query: z.optional(z.never()) 1671 + }); 1672 + 1673 + export const zDuplicateName2Data = z.object({ 1674 + body: z.optional(z.never()), 1675 + path: z.optional(z.never()), 1676 + query: z.optional(z.never()) 1677 + }); 1678 + 1679 + export const zDuplicateName3Data = z.object({ 1680 + body: z.optional(z.never()), 1681 + path: z.optional(z.never()), 1682 + query: z.optional(z.never()) 1683 + }); 1684 + 1685 + export const zDuplicateName4Data = z.object({ 1686 + body: z.optional(z.never()), 1687 + path: z.optional(z.never()), 1688 + query: z.optional(z.never()) 1689 + }); 1690 + 1691 + export const zCallWithNoContentResponseData = z.object({ 1692 + body: z.optional(z.never()), 1693 + path: z.optional(z.never()), 1694 + query: z.optional(z.never()) 1695 + }); 1696 + 1697 + /** 1698 + * Success 1699 + */ 1700 + export const zCallWithNoContentResponseResponse = z.void(); 1701 + 1702 + export const zCallWithResponseAndNoContentResponseData = z.object({ 1703 + body: z.optional(z.never()), 1704 + path: z.optional(z.never()), 1705 + query: z.optional(z.never()) 1706 + }); 1707 + 1708 + export const zCallWithResponseAndNoContentResponseResponse = z.union([ 1709 + z.number(), 1710 + z.void() 1711 + ]); 1712 + 1713 + export const zDummyAData = z.object({ 1714 + body: z.optional(z.never()), 1715 + path: z.optional(z.never()), 1716 + query: z.optional(z.never()) 1717 + }); 1718 + 1719 + export const zDummyAResponse = z400; 1720 + 1721 + export const zDummyBData = z.object({ 1722 + body: z.optional(z.never()), 1723 + path: z.optional(z.never()), 1724 + query: z.optional(z.never()) 1725 + }); 1726 + 1727 + /** 1728 + * Success 1729 + */ 1730 + export const zDummyBResponse = z.void(); 1731 + 1732 + export const zCallWithResponseData = z.object({ 1733 + body: z.optional(z.never()), 1734 + path: z.optional(z.never()), 1735 + query: z.optional(z.never()) 1736 + }); 1737 + 1738 + export const zCallWithResponseResponse = zImport; 1739 + 1740 + export const zCallWithDuplicateResponsesData = z.object({ 1741 + body: z.optional(z.never()), 1742 + path: z.optional(z.never()), 1743 + query: z.optional(z.never()) 1744 + }); 1745 + 1746 + export const zCallWithDuplicateResponsesResponse = z.union([ 1747 + z.intersection(zModelWithBoolean, zModelWithInteger), 1748 + zModelWithString 1749 + ]); 1750 + 1751 + export const zCallWithResponsesData = z.object({ 1752 + body: z.optional(z.never()), 1753 + path: z.optional(z.never()), 1754 + query: z.optional(z.never()) 1755 + }); 1756 + 1757 + export const zCallWithResponsesResponse = z.union([ 1758 + z.object({ 1759 + '@namespace.string': z.optional(z.readonly(z.string())), 1760 + '@namespace.integer': z.optional(z.readonly(z.int())), 1761 + value: z.optional(z.readonly(z.array(zModelWithString))) 1762 + }), 1763 + zModelThatExtends, 1764 + zModelThatExtendsExtends 1765 + ]); 1766 + 1767 + export const zCollectionFormatData = z.object({ 1768 + body: z.optional(z.never()), 1769 + path: z.optional(z.never()), 1770 + query: z.object({ 1771 + parameterArrayCSV: z.union([ 1772 + z.array(z.string()), 1773 + z.null() 1774 + ]), 1775 + parameterArraySSV: z.union([ 1776 + z.array(z.string()), 1777 + z.null() 1778 + ]), 1779 + parameterArrayTSV: z.union([ 1780 + z.array(z.string()), 1781 + z.null() 1782 + ]), 1783 + parameterArrayPipes: z.union([ 1784 + z.array(z.string()), 1785 + z.null() 1786 + ]), 1787 + parameterArrayMulti: z.union([ 1788 + z.array(z.string()), 1789 + z.null() 1790 + ]) 1791 + }) 1792 + }); 1793 + 1794 + export const zTypesData = z.object({ 1795 + body: z.optional(z.never()), 1796 + path: z.optional(z.object({ 1797 + id: z.optional(z.int()) 1798 + })), 1799 + query: z.object({ 1800 + parameterNumber: z._default(z.number(), 123), 1801 + parameterString: z._default(z.union([ 1802 + z._default(z.string(), 'default'), 1803 + z.null() 1804 + ]), 'default'), 1805 + parameterBoolean: z._default(z.union([ 1806 + z._default(z.boolean(), true), 1807 + z.null() 1808 + ]), true), 1809 + parameterObject: z._default(z.union([ 1810 + z.object({}), 1811 + z.null() 1812 + ]), null), 1813 + parameterArray: z.union([ 1814 + z.array(z.string()), 1815 + z.null() 1816 + ]), 1817 + parameterDictionary: z.union([ 1818 + z.object({}), 1819 + z.null() 1820 + ]), 1821 + parameterEnum: z.union([ 1822 + z.literal('Success'), 1823 + z.literal('Warning'), 1824 + z.literal('Error'), 1825 + z.null() 1826 + ]) 1827 + }) 1828 + }); 1829 + 1830 + export const zTypesResponse = z.union([ 1831 + z.number(), 1832 + z.string(), 1833 + z.boolean(), 1834 + z.object({}) 1835 + ]); 1836 + 1837 + export const zUploadFileData = z.object({ 1838 + body: z.string(), 1839 + path: z.object({ 1840 + 'api-version': z.union([ 1841 + z.string(), 1842 + z.null() 1843 + ]) 1844 + }), 1845 + query: z.optional(z.never()) 1846 + }); 1847 + 1848 + export const zUploadFileResponse = z.boolean(); 1849 + 1850 + export const zFileResponseData = z.object({ 1851 + body: z.optional(z.never()), 1852 + path: z.object({ 1853 + id: z.string(), 1854 + 'api-version': z.string() 1855 + }), 1856 + query: z.optional(z.never()) 1857 + }); 1858 + 1859 + /** 1860 + * Success 1861 + */ 1862 + export const zFileResponseResponse = z.string(); 1863 + 1864 + export const zComplexTypesData = z.object({ 1865 + body: z.optional(z.never()), 1866 + path: z.optional(z.never()), 1867 + query: z.object({ 1868 + parameterObject: z.object({ 1869 + first: z.optional(z.object({ 1870 + second: z.optional(z.object({ 1871 + third: z.optional(z.string()) 1872 + })) 1873 + })) 1874 + }), 1875 + parameterReference: zModelWithString 1876 + }) 1877 + }); 1878 + 1879 + /** 1880 + * Successful response 1881 + */ 1882 + export const zComplexTypesResponse = z.array(zModelWithString); 1883 + 1884 + export const zMultipartResponseData = z.object({ 1885 + body: z.optional(z.never()), 1886 + path: z.optional(z.never()), 1887 + query: z.optional(z.never()) 1888 + }); 1889 + 1890 + /** 1891 + * OK 1892 + */ 1893 + export const zMultipartResponseResponse = z.object({ 1894 + file: z.optional(z.string()), 1895 + metadata: z.optional(z.object({ 1896 + foo: z.optional(z.string()), 1897 + bar: z.optional(z.string()) 1898 + })) 1899 + }); 1900 + 1901 + export const zMultipartRequestData = z.object({ 1902 + body: z.optional(z.object({ 1903 + content: z.optional(z.string()), 1904 + data: z.optional(z.union([ 1905 + zModelWithString, 1906 + z.null() 1907 + ])) 1908 + })), 1909 + path: z.optional(z.never()), 1910 + query: z.optional(z.never()) 1911 + }); 1912 + 1913 + export const zComplexParamsData = z.object({ 1914 + body: z.optional(z.object({ 1915 + key: z.readonly(z.union([ 1916 + z.readonly(z.string().check(z.maxLength(64), z.regex(/^[a-zA-Z0-9_]*$/))), 1917 + z.null() 1918 + ])), 1919 + name: z.union([ 1920 + z.string().check(z.maxLength(255)), 1921 + z.null() 1922 + ]), 1923 + enabled: z._default(z.optional(z.boolean()), true), 1924 + type: z.enum([ 1925 + 'Monkey', 1926 + 'Horse', 1927 + 'Bird' 1928 + ]), 1929 + listOfModels: z.optional(z.union([ 1930 + z.array(zModelWithString), 1931 + z.null() 1932 + ])), 1933 + listOfStrings: z.optional(z.union([ 1934 + z.array(z.string()), 1935 + z.null() 1936 + ])), 1937 + parameters: z.union([ 1938 + zModelWithString, 1939 + zModelWithEnum, 1940 + zModelWithArray, 1941 + zModelWithDictionary 1942 + ]), 1943 + user: z.optional(z.readonly(z.object({ 1944 + id: z.optional(z.readonly(z.int())), 1945 + name: z.optional(z.readonly(z.union([ 1946 + z.readonly(z.string()), 1947 + z.null() 1948 + ]))) 1949 + }))) 1950 + })), 1951 + path: z.object({ 1952 + id: z.int(), 1953 + 'api-version': z.string() 1954 + }), 1955 + query: z.optional(z.never()) 1956 + }); 1957 + 1958 + /** 1959 + * Success 1960 + */ 1961 + export const zComplexParamsResponse = zModelWithString; 1962 + 1963 + export const zCallWithResultFromHeaderData = z.object({ 1964 + body: z.optional(z.never()), 1965 + path: z.optional(z.never()), 1966 + query: z.optional(z.never()) 1967 + }); 1968 + 1969 + export const zTestErrorCodeData = z.object({ 1970 + body: z.optional(z.never()), 1971 + path: z.optional(z.never()), 1972 + query: z.object({ 1973 + status: z.int() 1974 + }) 1975 + }); 1976 + 1977 + export const zNonAsciiæøåÆøÅöôêÊ字符串Data = z.object({ 1978 + body: z.optional(z.never()), 1979 + path: z.optional(z.never()), 1980 + query: z.object({ 1981 + 'nonAsciiParamæøåÆØÅöôêÊ': z.int() 1982 + }) 1983 + }); 1984 + 1985 + /** 1986 + * Successful response 1987 + */ 1988 + export const zNonAsciiæøåÆøÅöôêÊ字符串Response = z.array(zNonAsciiStringæøåÆøÅöôêÊ字符串); 1989 + 1990 + export const zPutWithFormUrlEncodedData = z.object({ 1991 + body: zArrayWithStringsWritable, 1992 + path: z.optional(z.never()), 1993 + query: z.optional(z.never()) 1994 + });
+18
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/enum-null/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as z from 'zod/mini'; 4 + 5 + export const zFoo = z.nullable(z.enum([ 6 + 'foo', 7 + 'bar' 8 + ])); 9 + 10 + export const zBar = z.enum([ 11 + 'foo', 12 + 'bar' 13 + ]); 14 + 15 + export const zBaz = z.enum([ 16 + 'foo', 17 + 'bar' 18 + ]);
+19
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/schema-const/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as z from 'zod/mini'; 4 + 5 + export const zFoo = z.object({ 6 + foo: z.optional(z.literal('foo')), 7 + bar: z.optional(z.literal(3.2)), 8 + baz: z.optional(z.literal(-1)), 9 + qux: z.optional(z.literal(true)), 10 + quux: z.optional(z.tuple([ 11 + z.literal(1), 12 + z.literal(2), 13 + z.literal(3), 14 + z.literal('foo'), 15 + z.literal(true) 16 + ])), 17 + corge: z.optional(z.object({})), 18 + garply: z.optional(z.coerce.bigint()) 19 + });
+24
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/type-format-zod/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as z from 'zod/mini'; 4 + 5 + export const zFoo = z.object({ 6 + bar: z.optional(z.int()), 7 + foo: z._default(z.coerce.bigint(), BigInt(0)), 8 + id: z.string() 9 + }); 10 + 11 + export const zBar = z.object({ 12 + foo: z.int() 13 + }); 14 + 15 + export const zPostFooData = z.object({ 16 + body: z.optional(z.never()), 17 + path: z.optional(z.never()), 18 + query: z.optional(z.never()) 19 + }); 20 + 21 + /** 22 + * OK 23 + */ 24 + export const zPostFooResponse = zFoo;
+7
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-bigint-min-max/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as z from 'zod/mini'; 4 + 5 + export const zFoo = z.object({ 6 + foo: z.optional(z.coerce.bigint().check(z.gte(BigInt(0)), z.lte(BigInt(100)))) 7 + });
+16
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-circular-ref-2/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as z from 'zod/mini'; 4 + 5 + export const zBar = z.object({ 6 + bar: z.union([ 7 + z.array(z.lazy((): any => { 8 + return zBar; 9 + })), 10 + z.null() 11 + ]) 12 + }); 13 + 14 + export const zFoo = z.object({ 15 + foo: zBar 16 + });
+24
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-circular-ref/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as z from 'zod/mini'; 4 + 5 + export const zBar = z.object({ 6 + get bar(): z.ZodMiniOptional { 7 + return z.optional(z.array(z.lazy((): any => { 8 + return zBar; 9 + }))); 10 + } 11 + }); 12 + 13 + export const zFoo = z.object({ 14 + foo: z.optional(zBar) 15 + }); 16 + 17 + /** 18 + * description caused circular reference error 19 + */ 20 + export const zQux = z.lazy((): any => { 21 + return zQux; 22 + }); 23 + 24 + export const zBaz = zQux;
+68
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-dates/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as z from 'zod/mini'; 4 + 5 + /** 6 + * This is Bar schema. 7 + */ 8 + export const zBar = z.object({ 9 + get foo(): z.ZodMiniOptional { 10 + return z.optional(zFoo); 11 + } 12 + }); 13 + 14 + /** 15 + * This is Foo schema. 16 + */ 17 + export const zFoo = z._default(z.union([ 18 + z.object({ 19 + foo: z.optional(z.string().check(z.regex(/^\d{3}-\d{2}-\d{4}$/))), 20 + bar: z.optional(zBar), 21 + get baz(): z.ZodMiniOptional { 22 + return z.optional(z.array(z.lazy((): any => { 23 + return zFoo; 24 + }))); 25 + }, 26 + qux: z._default(z.optional(z.int().check(z.gt(0))), 0) 27 + }), 28 + z.null() 29 + ]), null); 30 + 31 + export const zBaz = z._default(z.readonly(z.string().check(z.regex(/foo\nbar/))), 'baz'); 32 + 33 + export const zQux = z.record(z.string(), z.object({ 34 + qux: z.optional(z.string()) 35 + })); 36 + 37 + /** 38 + * This is Foo parameter. 39 + */ 40 + export const zFoo2 = z.string(); 41 + 42 + export const zFoo3 = z.object({ 43 + foo: z.optional(zBar) 44 + }); 45 + 46 + export const zPatchFooData = z.object({ 47 + body: z.object({ 48 + foo: z.optional(z.string()) 49 + }), 50 + path: z.optional(z.never()), 51 + query: z.optional(z.object({ 52 + foo: z.optional(z.string()), 53 + bar: z.optional(zBar), 54 + baz: z.optional(z.object({ 55 + baz: z.optional(z.string()) 56 + })), 57 + qux: z.optional(z.iso.date()), 58 + quux: z.optional(z.iso.datetime({ 59 + offset: true 60 + })) 61 + })) 62 + }); 63 + 64 + export const zPostFooData = z.object({ 65 + body: zFoo3, 66 + path: z.optional(z.never()), 67 + query: z.optional(z.never()) 68 + });
+78
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-metadata/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as z from 'zod/mini'; 4 + 5 + /** 6 + * This is Bar schema. 7 + */ 8 + export const zBar = z.object({ 9 + get foo(): z.ZodMiniOptional { 10 + return z.optional(zFoo); 11 + } 12 + }).register(z.globalRegistry, { 13 + description: 'This is Bar schema.' 14 + }); 15 + 16 + /** 17 + * This is Foo schema. 18 + */ 19 + export const zFoo = z._default(z.union([ 20 + z.object({ 21 + foo: z.optional(z.string().check(z.regex(/^\d{3}-\d{2}-\d{4}$/)).register(z.globalRegistry, { 22 + description: 'This is foo property.' 23 + })), 24 + bar: z.optional(zBar), 25 + get baz(): z.ZodMiniOptional { 26 + return z.optional(z.array(z.lazy((): any => { 27 + return zFoo; 28 + })).register(z.globalRegistry, { 29 + description: 'This is baz property.' 30 + })); 31 + }, 32 + qux: z._default(z.optional(z.int().check(z.gt(0)).register(z.globalRegistry, { 33 + description: 'This is qux property.' 34 + })), 0) 35 + }), 36 + z.null() 37 + ]), null); 38 + 39 + export const zBaz = z._default(z.readonly(z.string().check(z.regex(/foo\nbar/))), 'baz'); 40 + 41 + export const zQux = z.record(z.string(), z.object({ 42 + qux: z.optional(z.string()) 43 + })); 44 + 45 + /** 46 + * This is Foo parameter. 47 + */ 48 + export const zFoo2 = z.string().register(z.globalRegistry, { 49 + description: 'This is Foo parameter.' 50 + }); 51 + 52 + export const zFoo3 = z.object({ 53 + foo: z.optional(zBar) 54 + }); 55 + 56 + export const zPatchFooData = z.object({ 57 + body: z.object({ 58 + foo: z.optional(z.string()) 59 + }), 60 + path: z.optional(z.never()), 61 + query: z.optional(z.object({ 62 + foo: z.optional(z.string().register(z.globalRegistry, { 63 + description: 'This is Foo parameter.' 64 + })), 65 + bar: z.optional(zBar), 66 + baz: z.optional(z.object({ 67 + baz: z.optional(z.string()) 68 + })), 69 + qux: z.optional(z.iso.date()), 70 + quux: z.optional(z.iso.datetime()) 71 + })) 72 + }); 73 + 74 + export const zPostFooData = z.object({ 75 + body: zFoo3, 76 + path: z.optional(z.never()), 77 + query: z.optional(z.never()) 78 + });
+82
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-types/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as z from 'zod/mini'; 4 + 5 + /** 6 + * This is Bar schema. 7 + */ 8 + export const zBar = z.object({ 9 + get foo(): z.ZodMiniOptional { 10 + return z.optional(zFoo); 11 + } 12 + }); 13 + 14 + export type BarZodType = z.infer<typeof zBar>; 15 + 16 + /** 17 + * This is Foo schema. 18 + */ 19 + export const zFoo = z._default(z.union([ 20 + z.object({ 21 + foo: z.optional(z.string().check(z.regex(/^\d{3}-\d{2}-\d{4}$/))), 22 + bar: z.optional(zBar), 23 + get baz(): z.ZodMiniOptional { 24 + return z.optional(z.array(z.lazy((): any => { 25 + return zFoo; 26 + }))); 27 + }, 28 + qux: z._default(z.optional(z.int().check(z.gt(0))), 0) 29 + }), 30 + z.null() 31 + ]), null); 32 + 33 + export type FooZodType = z.infer<typeof zFoo>; 34 + 35 + export const zBaz = z._default(z.readonly(z.string().check(z.regex(/foo\nbar/))), 'baz'); 36 + 37 + export type BazZodType = z.infer<typeof zBaz>; 38 + 39 + export const zQux = z.record(z.string(), z.object({ 40 + qux: z.optional(z.string()) 41 + })); 42 + 43 + export type QuxZodType = z.infer<typeof zQux>; 44 + 45 + /** 46 + * This is Foo parameter. 47 + */ 48 + export const zFoo2 = z.string(); 49 + 50 + export type FooZodType2 = z.infer<typeof zFoo2>; 51 + 52 + export const zFoo3 = z.object({ 53 + foo: z.optional(zBar) 54 + }); 55 + 56 + export type FooZodType3 = z.infer<typeof zFoo3>; 57 + 58 + export const zPatchFooData = z.object({ 59 + body: z.object({ 60 + foo: z.optional(z.string()) 61 + }), 62 + path: z.optional(z.never()), 63 + query: z.optional(z.object({ 64 + foo: z.optional(z.string()), 65 + bar: z.optional(zBar), 66 + baz: z.optional(z.object({ 67 + baz: z.optional(z.string()) 68 + })), 69 + qux: z.optional(z.iso.date()), 70 + quux: z.optional(z.iso.datetime()) 71 + })) 72 + }); 73 + 74 + export type PatchFooDataZodType = z.infer<typeof zPatchFooData>; 75 + 76 + export const zPostFooData = z.object({ 77 + body: zFoo3, 78 + path: z.optional(z.never()), 79 + query: z.optional(z.never()) 80 + }); 81 + 82 + export type PostFooDataZodType = z.infer<typeof zPostFooData>;
+44
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators-union-merge/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as z from 'zod/mini'; 4 + 5 + export const zContact = z.union([ 6 + z.object({ 7 + email: z.string() 8 + }), 9 + z.object({ 10 + phone: z.string() 11 + }) 12 + ]); 13 + 14 + export const zUser = z.intersection(zContact, z.object({ 15 + username: z.string() 16 + })); 17 + 18 + export const zDogDetails = z.object({ 19 + breed: z.string(), 20 + barkVolume: z.int().check(z.gte(1), z.lte(10)) 21 + }); 22 + 23 + export const zCatDetails = z.object({ 24 + furLength: z.enum([ 25 + 'short', 26 + 'medium', 27 + 'long' 28 + ]), 29 + purrs: z.boolean() 30 + }); 31 + 32 + export const zPetStore = z.object({ 33 + animals: z.array(z.object({ 34 + name: z.string(), 35 + type: z.optional(z.enum([ 36 + 'dog', 37 + 'cat' 38 + ])), 39 + details: z.union([ 40 + zDogDetails, 41 + zCatDetails 42 + ]) 43 + })) 44 + });
+66
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/mini/validators/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import * as z from 'zod/mini'; 4 + 5 + /** 6 + * This is Bar schema. 7 + */ 8 + export const zBar = z.object({ 9 + get foo(): z.ZodMiniOptional { 10 + return z.optional(zFoo); 11 + } 12 + }); 13 + 14 + /** 15 + * This is Foo schema. 16 + */ 17 + export const zFoo = z._default(z.union([ 18 + z.object({ 19 + foo: z.optional(z.string().check(z.regex(/^\d{3}-\d{2}-\d{4}$/))), 20 + bar: z.optional(zBar), 21 + get baz(): z.ZodMiniOptional { 22 + return z.optional(z.array(z.lazy((): any => { 23 + return zFoo; 24 + }))); 25 + }, 26 + qux: z._default(z.optional(z.int().check(z.gt(0))), 0) 27 + }), 28 + z.null() 29 + ]), null); 30 + 31 + export const zBaz = z._default(z.readonly(z.string().check(z.regex(/foo\nbar/))), 'baz'); 32 + 33 + export const zQux = z.record(z.string(), z.object({ 34 + qux: z.optional(z.string()) 35 + })); 36 + 37 + /** 38 + * This is Foo parameter. 39 + */ 40 + export const zFoo2 = z.string(); 41 + 42 + export const zFoo3 = z.object({ 43 + foo: z.optional(zBar) 44 + }); 45 + 46 + export const zPatchFooData = z.object({ 47 + body: z.object({ 48 + foo: z.optional(z.string()) 49 + }), 50 + path: z.optional(z.never()), 51 + query: z.optional(z.object({ 52 + foo: z.optional(z.string()), 53 + bar: z.optional(zBar), 54 + baz: z.optional(z.object({ 55 + baz: z.optional(z.string()) 56 + })), 57 + qux: z.optional(z.iso.date()), 58 + quux: z.optional(z.iso.datetime()) 59 + })) 60 + }); 61 + 62 + export const zPostFooData = z.object({ 63 + body: zFoo3, 64 + path: z.optional(z.never()), 65 + query: z.optional(z.never()) 66 + });
+9
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/array-items-one-of-length-1/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod/v3'; 4 + 5 + export const zBar = z.string(); 6 + 7 + export const zFoo = z.object({ 8 + foo: z.array(zBar).min(1).max(2147483647).optional() 9 + });
+1992
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/default/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod/v3'; 4 + 5 + /** 6 + * Model with number-only name 7 + */ 8 + export const z400 = z.string(); 9 + 10 + /** 11 + * Testing multiline comments in string: First line 12 + * Second line 13 + * 14 + * Fourth line 15 + */ 16 + export const zCamelCaseCommentWithBreaks = z.number().int(); 17 + 18 + /** 19 + * Testing multiline comments in string: First line 20 + * Second line 21 + * 22 + * Fourth line 23 + */ 24 + export const zCommentWithBreaks = z.number().int(); 25 + 26 + /** 27 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 28 + */ 29 + export const zCommentWithBackticks = z.number().int(); 30 + 31 + /** 32 + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 33 + */ 34 + export const zCommentWithBackticksAndQuotes = z.number().int(); 35 + 36 + /** 37 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 38 + */ 39 + export const zCommentWithSlashes = z.number().int(); 40 + 41 + /** 42 + * Testing expression placeholders in string: ${expression} should work 43 + */ 44 + export const zCommentWithExpressionPlaceholders = z.number().int(); 45 + 46 + /** 47 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 48 + */ 49 + export const zCommentWithQuotes = z.number().int(); 50 + 51 + /** 52 + * Testing reserved characters in string: * inline * and ** inline ** should work 53 + */ 54 + export const zCommentWithReservedCharacters = z.number().int(); 55 + 56 + /** 57 + * This is a simple number 58 + */ 59 + export const zSimpleInteger = z.number().int(); 60 + 61 + /** 62 + * This is a simple boolean 63 + */ 64 + export const zSimpleBoolean = z.boolean(); 65 + 66 + /** 67 + * This is a simple string 68 + */ 69 + export const zSimpleString = z.string(); 70 + 71 + /** 72 + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 73 + */ 74 + export const zNonAsciiStringæøåÆøÅöôêÊ字符串 = z.string(); 75 + 76 + /** 77 + * This is a simple file 78 + */ 79 + export const zSimpleFile = z.string(); 80 + 81 + /** 82 + * This is a model with one string property 83 + */ 84 + export const zModelWithString = z.object({ 85 + prop: z.string().optional() 86 + }); 87 + 88 + /** 89 + * This is a simple reference 90 + */ 91 + export const zSimpleReference = zModelWithString; 92 + 93 + /** 94 + * This is a simple string 95 + */ 96 + export const zSimpleStringWithPattern = z.union([ 97 + z.string().max(64).regex(/^[a-zA-Z0-9_]*$/), 98 + z.null() 99 + ]); 100 + 101 + /** 102 + * This is a simple enum with strings 103 + */ 104 + export const zEnumWithStrings = z.enum([ 105 + 'Success', 106 + 'Warning', 107 + 'Error', 108 + "'Single Quote'", 109 + '"Double Quotes"', 110 + 'Non-ascii: øæåôöØÆÅÔÖ字符串' 111 + ]); 112 + 113 + export const zEnumWithReplacedCharacters = z.enum([ 114 + "'Single Quote'", 115 + '"Double Quotes"', 116 + 'øæåôöØÆÅÔÖ字符串', 117 + '' 118 + ]); 119 + 120 + /** 121 + * This is a simple enum with numbers 122 + */ 123 + export const zEnumWithNumbers = z.unknown(); 124 + 125 + /** 126 + * Success=1,Warning=2,Error=3 127 + */ 128 + export const zEnumFromDescription = z.number(); 129 + 130 + /** 131 + * This is a simple enum with numbers 132 + */ 133 + export const zEnumWithExtensions = z.unknown(); 134 + 135 + export const zEnumWithXEnumNames = z.unknown(); 136 + 137 + /** 138 + * This is a simple array with numbers 139 + */ 140 + export const zArrayWithNumbers = z.array(z.number().int()); 141 + 142 + /** 143 + * This is a simple array with booleans 144 + */ 145 + export const zArrayWithBooleans = z.array(z.boolean()); 146 + 147 + /** 148 + * This is a simple array with strings 149 + */ 150 + export const zArrayWithStrings = z.array(z.string()).default(['test']); 151 + 152 + /** 153 + * This is a simple array with references 154 + */ 155 + export const zArrayWithReferences = z.array(zModelWithString); 156 + 157 + /** 158 + * This is a simple array containing an array 159 + */ 160 + export const zArrayWithArray = z.array(z.array(zModelWithString)); 161 + 162 + /** 163 + * This is a simple array with properties 164 + */ 165 + export const zArrayWithProperties = z.array(z.object({ 166 + '16x16': zCamelCaseCommentWithBreaks.optional(), 167 + bar: z.string().optional() 168 + })); 169 + 170 + /** 171 + * This is a simple array with any of properties 172 + */ 173 + export const zArrayWithAnyOfProperties = z.array(z.union([ 174 + z.object({ 175 + foo: z.string().optional().default('test') 176 + }), 177 + z.object({ 178 + bar: z.string().optional() 179 + }) 180 + ])); 181 + 182 + export const zAnyOfAnyAndNull = z.object({ 183 + data: z.union([ 184 + z.unknown(), 185 + z.null() 186 + ]).optional() 187 + }); 188 + 189 + /** 190 + * This is a simple array with any of properties 191 + */ 192 + export const zAnyOfArrays = z.object({ 193 + results: z.array(z.union([ 194 + z.object({ 195 + foo: z.string().optional() 196 + }), 197 + z.object({ 198 + bar: z.string().optional() 199 + }) 200 + ])).optional() 201 + }); 202 + 203 + /** 204 + * This is a string dictionary 205 + */ 206 + export const zDictionaryWithString = z.object({}); 207 + 208 + export const zDictionaryWithPropertiesAndAdditionalProperties = z.object({ 209 + foo: z.number().optional(), 210 + bar: z.boolean().optional() 211 + }); 212 + 213 + /** 214 + * This is a string reference 215 + */ 216 + export const zDictionaryWithReference = z.object({}); 217 + 218 + /** 219 + * This is a complex dictionary 220 + */ 221 + export const zDictionaryWithArray = z.object({}); 222 + 223 + /** 224 + * This is a string dictionary 225 + */ 226 + export const zDictionaryWithDictionary = z.record(z.object({})); 227 + 228 + /** 229 + * This is a complex dictionary 230 + */ 231 + export const zDictionaryWithProperties = z.record(z.object({ 232 + foo: z.string().optional(), 233 + bar: z.string().optional() 234 + })); 235 + 236 + /** 237 + * This is a model with one number property 238 + */ 239 + export const zModelWithInteger = z.object({ 240 + prop: z.number().int().optional() 241 + }); 242 + 243 + /** 244 + * This is a model with one boolean property 245 + */ 246 + export const zModelWithBoolean = z.object({ 247 + prop: z.boolean().optional() 248 + }); 249 + 250 + /** 251 + * This is a model with one string property 252 + */ 253 + export const zModelWithStringError = z.object({ 254 + prop: z.string().optional() 255 + }); 256 + 257 + /** 258 + * `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) 259 + */ 260 + export const zModelFromZendesk = z.string(); 261 + 262 + /** 263 + * This is a model with one string property 264 + */ 265 + export const zModelWithNullableString = z.object({ 266 + nullableProp1: z.union([ 267 + z.string(), 268 + z.null() 269 + ]).optional(), 270 + nullableRequiredProp1: z.union([ 271 + z.string(), 272 + z.null() 273 + ]), 274 + nullableProp2: z.union([ 275 + z.string(), 276 + z.null() 277 + ]).optional(), 278 + nullableRequiredProp2: z.union([ 279 + z.string(), 280 + z.null() 281 + ]), 282 + 'foo_bar-enum': z.enum([ 283 + 'Success', 284 + 'Warning', 285 + 'Error', 286 + 'ØÆÅ字符串' 287 + ]).optional() 288 + }); 289 + 290 + /** 291 + * This is a model with one enum 292 + */ 293 + export const zModelWithEnum = z.object({ 294 + 'foo_bar-enum': z.enum([ 295 + 'Success', 296 + 'Warning', 297 + 'Error', 298 + 'ØÆÅ字符串' 299 + ]).optional(), 300 + statusCode: z.enum([ 301 + '100', 302 + '200 FOO', 303 + '300 FOO_BAR', 304 + '400 foo-bar', 305 + '500 foo.bar', 306 + '600 foo&bar' 307 + ]).optional(), 308 + bool: z.unknown().optional() 309 + }); 310 + 311 + /** 312 + * This is a model with one enum with escaped name 313 + */ 314 + export const zModelWithEnumWithHyphen = z.object({ 315 + 'foo-bar-baz-qux': z.enum([ 316 + '3.0' 317 + ]).optional() 318 + }); 319 + 320 + /** 321 + * This is a model with one enum 322 + */ 323 + export const zModelWithEnumFromDescription = z.object({ 324 + test: z.number().int().optional() 325 + }); 326 + 327 + /** 328 + * This is a model with nested enums 329 + */ 330 + export const zModelWithNestedEnums = z.object({ 331 + dictionaryWithEnum: z.object({}).optional(), 332 + dictionaryWithEnumFromDescription: z.object({}).optional(), 333 + arrayWithEnum: z.array(z.enum([ 334 + 'Success', 335 + 'Warning', 336 + 'Error' 337 + ])).optional(), 338 + arrayWithDescription: z.array(z.number().int()).optional(), 339 + 'foo_bar-enum': z.enum([ 340 + 'Success', 341 + 'Warning', 342 + 'Error', 343 + 'ØÆÅ字符串' 344 + ]).optional() 345 + }); 346 + 347 + /** 348 + * This is a model with one nested property 349 + */ 350 + export const zModelWithProperties = z.object({ 351 + required: z.string(), 352 + requiredAndReadOnly: z.string().readonly(), 353 + requiredAndNullable: z.union([ 354 + z.string(), 355 + z.null() 356 + ]), 357 + string: z.string().optional(), 358 + number: z.number().optional(), 359 + boolean: z.boolean().optional(), 360 + reference: zModelWithString.optional(), 361 + 'property with space': z.string().optional(), 362 + default: z.string().optional(), 363 + try: z.string().optional(), 364 + '@namespace.string': z.string().readonly().optional(), 365 + '@namespace.integer': z.number().int().readonly().optional() 366 + }); 367 + 368 + /** 369 + * This is a model with one property containing a reference 370 + */ 371 + export const zModelWithReference = z.object({ 372 + prop: zModelWithProperties.optional() 373 + }); 374 + 375 + export const zModelWithReadOnlyAndWriteOnly = z.object({ 376 + foo: z.string(), 377 + bar: z.string().readonly() 378 + }); 379 + 380 + /** 381 + * This is a model with one property containing an array 382 + */ 383 + export const zModelWithArrayReadOnlyAndWriteOnly = z.object({ 384 + prop: z.array(zModelWithReadOnlyAndWriteOnly).optional(), 385 + propWithFile: z.array(z.string()).optional(), 386 + propWithNumber: z.array(z.number()).optional() 387 + }); 388 + 389 + /** 390 + * This is a model with one property containing an array 391 + */ 392 + export const zModelWithArray = z.object({ 393 + prop: z.array(zModelWithString).optional(), 394 + propWithFile: z.array(z.string()).optional(), 395 + propWithNumber: z.array(z.number()).optional() 396 + }); 397 + 398 + /** 399 + * This is a model with one property containing a dictionary 400 + */ 401 + export const zModelWithDictionary = z.object({ 402 + prop: z.object({}).optional() 403 + }); 404 + 405 + /** 406 + * This is a deprecated model with a deprecated property 407 + * @deprecated 408 + */ 409 + export const zDeprecatedModel = z.object({ 410 + prop: z.string().optional() 411 + }); 412 + 413 + /** 414 + * This is a model with one property containing a circular reference 415 + */ 416 + export const zModelWithCircularReference: z.AnyZodObject = z.object({ 417 + prop: z.lazy(() => { 418 + return zModelWithCircularReference; 419 + }).optional() 420 + }); 421 + 422 + /** 423 + * This is a model with one property with a 'one of' relationship 424 + */ 425 + export const zCompositionWithOneOf = z.object({ 426 + propA: z.union([ 427 + zModelWithString, 428 + zModelWithEnum, 429 + zModelWithArray, 430 + zModelWithDictionary 431 + ]).optional() 432 + }); 433 + 434 + /** 435 + * This is a model with one property with a 'one of' relationship where the options are not $ref 436 + */ 437 + export const zCompositionWithOneOfAnonymous = z.object({ 438 + propA: z.union([ 439 + z.object({ 440 + propA: z.string().optional() 441 + }), 442 + z.string(), 443 + z.number().int() 444 + ]).optional() 445 + }); 446 + 447 + /** 448 + * Circle 449 + */ 450 + export const zModelCircle = z.object({ 451 + kind: z.string(), 452 + radius: z.number().optional() 453 + }); 454 + 455 + /** 456 + * Square 457 + */ 458 + export const zModelSquare = z.object({ 459 + kind: z.string(), 460 + sideLength: z.number().optional() 461 + }); 462 + 463 + /** 464 + * This is a model with one property with a 'one of' relationship where the options are not $ref 465 + */ 466 + export const zCompositionWithOneOfDiscriminator = z.union([ 467 + z.object({ 468 + kind: z.literal('circle') 469 + }).and(zModelCircle), 470 + z.object({ 471 + kind: z.literal('square') 472 + }).and(zModelSquare) 473 + ]); 474 + 475 + /** 476 + * This is a model with one property with a 'any of' relationship 477 + */ 478 + export const zCompositionWithAnyOf = z.object({ 479 + propA: z.union([ 480 + zModelWithString, 481 + zModelWithEnum, 482 + zModelWithArray, 483 + zModelWithDictionary 484 + ]).optional() 485 + }); 486 + 487 + /** 488 + * This is a model with one property with a 'any of' relationship where the options are not $ref 489 + */ 490 + export const zCompositionWithAnyOfAnonymous = z.object({ 491 + propA: z.union([ 492 + z.object({ 493 + propA: z.string().optional() 494 + }), 495 + z.string(), 496 + z.number().int() 497 + ]).optional() 498 + }); 499 + 500 + /** 501 + * This is a model with nested 'any of' property with a type null 502 + */ 503 + export const zCompositionWithNestedAnyAndTypeNull = z.object({ 504 + propA: z.union([ 505 + z.array(z.union([ 506 + zModelWithDictionary, 507 + z.null() 508 + ])), 509 + z.array(z.union([ 510 + zModelWithArray, 511 + z.null() 512 + ])) 513 + ]).optional() 514 + }); 515 + 516 + export const z3eNum1Период = z.enum([ 517 + 'Bird', 518 + 'Dog' 519 + ]); 520 + 521 + export const zConstValue = z.literal('ConstValue'); 522 + 523 + /** 524 + * This is a model with one property with a 'any of' relationship where the options are not $ref 525 + */ 526 + export const zCompositionWithNestedAnyOfAndNull = z.object({ 527 + propA: z.union([ 528 + z.array(z.union([ 529 + z3eNum1Период, 530 + zConstValue 531 + ])), 532 + z.null() 533 + ]).optional() 534 + }); 535 + 536 + /** 537 + * This is a model with one property with a 'one of' relationship 538 + */ 539 + export const zCompositionWithOneOfAndNullable = z.object({ 540 + propA: z.union([ 541 + z.object({ 542 + boolean: z.boolean().optional() 543 + }), 544 + zModelWithEnum, 545 + zModelWithArray, 546 + zModelWithDictionary, 547 + z.null() 548 + ]).optional() 549 + }); 550 + 551 + /** 552 + * This is a model that contains a simple dictionary within composition 553 + */ 554 + export const zCompositionWithOneOfAndSimpleDictionary = z.object({ 555 + propA: z.union([ 556 + z.boolean(), 557 + z.object({}) 558 + ]).optional() 559 + }); 560 + 561 + /** 562 + * This is a model that contains a dictionary of simple arrays within composition 563 + */ 564 + export const zCompositionWithOneOfAndSimpleArrayDictionary = z.object({ 565 + propA: z.union([ 566 + z.boolean(), 567 + z.object({}) 568 + ]).optional() 569 + }); 570 + 571 + /** 572 + * This is a model that contains a dictionary of complex arrays (composited) within composition 573 + */ 574 + export const zCompositionWithOneOfAndComplexArrayDictionary = z.object({ 575 + propA: z.union([ 576 + z.boolean(), 577 + z.object({}) 578 + ]).optional() 579 + }); 580 + 581 + /** 582 + * This is a model with one property with a 'all of' relationship 583 + */ 584 + export const zCompositionWithAllOfAndNullable = z.object({ 585 + propA: z.union([ 586 + z.object({ 587 + boolean: z.boolean().optional() 588 + }).and(zModelWithEnum).and(zModelWithArray).and(zModelWithDictionary), 589 + z.null() 590 + ]).optional() 591 + }); 592 + 593 + /** 594 + * This is a model with one property with a 'any of' relationship 595 + */ 596 + export const zCompositionWithAnyOfAndNullable = z.object({ 597 + propA: z.union([ 598 + z.object({ 599 + boolean: z.boolean().optional() 600 + }), 601 + zModelWithEnum, 602 + zModelWithArray, 603 + zModelWithDictionary, 604 + z.null() 605 + ]).optional() 606 + }); 607 + 608 + /** 609 + * This is a base model with two simple optional properties 610 + */ 611 + export const zCompositionBaseModel = z.object({ 612 + firstName: z.string().optional(), 613 + lastname: z.string().optional() 614 + }); 615 + 616 + /** 617 + * This is a model that extends the base model 618 + */ 619 + export const zCompositionExtendedModel = zCompositionBaseModel.and(z.object({ 620 + age: z.number(), 621 + firstName: z.string(), 622 + lastname: z.string() 623 + })); 624 + 625 + /** 626 + * This is a model with one nested property 627 + */ 628 + export const zModelWithNestedProperties = z.object({ 629 + first: z.union([ 630 + z.object({ 631 + second: z.union([ 632 + z.object({ 633 + third: z.union([ 634 + z.string().readonly(), 635 + z.null() 636 + ]).readonly() 637 + }).readonly(), 638 + z.null() 639 + ]).readonly() 640 + }).readonly(), 641 + z.null() 642 + ]).readonly() 643 + }); 644 + 645 + /** 646 + * This is a model with duplicated properties 647 + */ 648 + export const zModelWithDuplicateProperties = z.object({ 649 + prop: zModelWithString.optional() 650 + }); 651 + 652 + /** 653 + * This is a model with ordered properties 654 + */ 655 + export const zModelWithOrderedProperties = z.object({ 656 + zebra: z.string().optional(), 657 + apple: z.string().optional(), 658 + hawaii: z.string().optional() 659 + }); 660 + 661 + /** 662 + * This is a model with duplicated imports 663 + */ 664 + export const zModelWithDuplicateImports = z.object({ 665 + propA: zModelWithString.optional(), 666 + propB: zModelWithString.optional(), 667 + propC: zModelWithString.optional() 668 + }); 669 + 670 + /** 671 + * This is a model that extends another model 672 + */ 673 + export const zModelThatExtends = zModelWithString.and(z.object({ 674 + propExtendsA: z.string().optional(), 675 + propExtendsB: zModelWithString.optional() 676 + })); 677 + 678 + /** 679 + * This is a model that extends another model 680 + */ 681 + export const zModelThatExtendsExtends = zModelWithString.and(zModelThatExtends).and(z.object({ 682 + propExtendsC: z.string().optional(), 683 + propExtendsD: zModelWithString.optional() 684 + })); 685 + 686 + /** 687 + * This is a model that contains a some patterns 688 + */ 689 + export const zModelWithPattern = z.object({ 690 + key: z.string().max(64).regex(/^[a-zA-Z0-9_]*$/), 691 + name: z.string().max(255), 692 + enabled: z.boolean().readonly().optional(), 693 + modified: z.string().datetime().readonly().optional(), 694 + id: z.string().regex(/^\d{2}-\d{3}-\d{4}$/).optional(), 695 + text: z.string().regex(/^\w+$/).optional(), 696 + patternWithSingleQuotes: z.string().regex(/^[a-zA-Z0-9']*$/).optional(), 697 + patternWithNewline: z.string().regex(/aaa\nbbb/).optional(), 698 + patternWithBacktick: z.string().regex(/aaa`bbb/).optional() 699 + }); 700 + 701 + export const zFile = z.object({ 702 + id: z.string().min(1).readonly().optional(), 703 + updated_at: z.string().datetime().readonly().optional(), 704 + created_at: z.string().datetime().readonly().optional(), 705 + mime: z.string().min(1).max(24), 706 + file: z.string().url().readonly().optional() 707 + }); 708 + 709 + export const zDefault = z.object({ 710 + name: z.string().optional() 711 + }); 712 + 713 + export const zPageable = z.object({ 714 + page: z.number().int().gte(0).optional().default(0), 715 + size: z.number().int().gte(1).optional(), 716 + sort: z.array(z.string()).optional() 717 + }); 718 + 719 + /** 720 + * This is a free-form object without additionalProperties. 721 + */ 722 + export const zFreeFormObjectWithoutAdditionalProperties = z.object({}); 723 + 724 + /** 725 + * This is a free-form object with additionalProperties: true. 726 + */ 727 + export const zFreeFormObjectWithAdditionalPropertiesEqTrue = z.object({}); 728 + 729 + /** 730 + * This is a free-form object with additionalProperties: {}. 731 + */ 732 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObject = z.object({}); 733 + 734 + export const zModelWithConst = z.object({ 735 + String: z.literal('String').optional(), 736 + number: z.literal(0).optional(), 737 + null: z.null().optional(), 738 + withType: z.literal('Some string').optional() 739 + }); 740 + 741 + /** 742 + * This is a model with one property and additionalProperties: true 743 + */ 744 + export const zModelWithAdditionalPropertiesEqTrue = z.object({ 745 + prop: z.string().optional() 746 + }); 747 + 748 + export const zNestedAnyOfArraysNullable = z.object({ 749 + nullableArray: z.union([ 750 + z.array(z.union([ 751 + z.string(), 752 + z.boolean() 753 + ])), 754 + z.null() 755 + ]).optional() 756 + }); 757 + 758 + /** 759 + * This is a reusable parameter 760 + */ 761 + export const zSimpleParameter = z.unknown(); 762 + 763 + export const zCompositionWithOneOfAndProperties = z.intersection(z.union([ 764 + z.object({ 765 + foo: zSimpleParameter 766 + }), 767 + z.object({ 768 + bar: zNonAsciiStringæøåÆøÅöôêÊ字符串 769 + }) 770 + ]), z.object({ 771 + baz: z.union([ 772 + z.number().int().gte(0), 773 + z.null() 774 + ]), 775 + qux: z.number().int().gte(0) 776 + })); 777 + 778 + /** 779 + * An object that can be null 780 + */ 781 + export const zNullableObject = z.union([ 782 + z.object({ 783 + foo: z.string().optional() 784 + }), 785 + z.null() 786 + ]).default(null); 787 + 788 + /** 789 + * Some % character 790 + */ 791 + export const zCharactersInDescription = z.string(); 792 + 793 + export const zModelWithNullableObject = z.object({ 794 + data: zNullableObject.optional() 795 + }); 796 + 797 + export const zModelWithOneOfEnum = z.union([ 798 + z.object({ 799 + foo: z.enum([ 800 + 'Bar' 801 + ]) 802 + }), 803 + z.object({ 804 + foo: z.enum([ 805 + 'Baz' 806 + ]) 807 + }), 808 + z.object({ 809 + foo: z.enum([ 810 + 'Qux' 811 + ]) 812 + }), 813 + z.object({ 814 + content: z.string().datetime(), 815 + foo: z.enum([ 816 + 'Quux' 817 + ]) 818 + }), 819 + z.object({ 820 + content: z.tuple([ 821 + z.string().datetime(), 822 + z.string() 823 + ]), 824 + foo: z.enum([ 825 + 'Corge' 826 + ]) 827 + }) 828 + ]); 829 + 830 + export const zModelWithNestedArrayEnumsDataFoo = z.enum([ 831 + 'foo', 832 + 'bar' 833 + ]); 834 + 835 + export const zModelWithNestedArrayEnumsDataBar = z.enum([ 836 + 'baz', 837 + 'qux' 838 + ]); 839 + 840 + export const zModelWithNestedArrayEnumsData = z.object({ 841 + foo: z.array(zModelWithNestedArrayEnumsDataFoo).optional(), 842 + bar: z.array(zModelWithNestedArrayEnumsDataBar).optional() 843 + }); 844 + 845 + export const zModelWithNestedArrayEnums = z.object({ 846 + array_strings: z.array(z.string()).optional(), 847 + data: zModelWithNestedArrayEnumsData.optional() 848 + }); 849 + 850 + export const zModelWithNestedCompositionEnums = z.object({ 851 + foo: zModelWithNestedArrayEnumsDataFoo.optional() 852 + }); 853 + 854 + export const zModelWithConstantSizeArray = z.tuple([ 855 + z.number(), 856 + z.number() 857 + ]); 858 + 859 + export const zModelWithAnyOfConstantSizeArray = z.tuple([ 860 + z.union([ 861 + z.number(), 862 + z.string() 863 + ]), 864 + z.union([ 865 + z.number(), 866 + z.string() 867 + ]), 868 + z.union([ 869 + z.number(), 870 + z.string() 871 + ]) 872 + ]); 873 + 874 + export const zModelWithPrefixItemsConstantSizeArray = z.tuple([ 875 + zModelWithInteger, 876 + z.union([ 877 + z.number(), 878 + z.string() 879 + ]), 880 + z.string() 881 + ]); 882 + 883 + export const zModelWithAnyOfConstantSizeArrayNullable = z.tuple([ 884 + z.union([ 885 + z.number(), 886 + z.null(), 887 + z.string() 888 + ]), 889 + z.union([ 890 + z.number(), 891 + z.null(), 892 + z.string() 893 + ]), 894 + z.union([ 895 + z.number(), 896 + z.null(), 897 + z.string() 898 + ]) 899 + ]); 900 + 901 + /** 902 + * Model with restricted keyword name 903 + */ 904 + export const zImport = z.string(); 905 + 906 + export const zModelWithAnyOfConstantSizeArrayWithNSizeAndOptions = z.tuple([ 907 + z.union([ 908 + z.number(), 909 + zImport 910 + ]), 911 + z.union([ 912 + z.number(), 913 + zImport 914 + ]) 915 + ]); 916 + 917 + export const zModelWithAnyOfConstantSizeArrayAndIntersect = z.tuple([ 918 + z.intersection(z.number(), z.string()), 919 + z.intersection(z.number(), z.string()) 920 + ]); 921 + 922 + export const zModelWithNumericEnumUnion = z.object({ 923 + value: z.unknown().optional() 924 + }); 925 + 926 + /** 927 + * Some description with `back ticks` 928 + */ 929 + export const zModelWithBackticksInDescription = z.object({ 930 + template: z.string().optional() 931 + }); 932 + 933 + export const zModelWithOneOfAndProperties = z.intersection(z.union([ 934 + zSimpleParameter, 935 + zNonAsciiStringæøåÆøÅöôêÊ字符串 936 + ]), z.object({ 937 + baz: z.union([ 938 + z.number().int().gte(0), 939 + z.null() 940 + ]), 941 + qux: z.number().int().gte(0) 942 + })); 943 + 944 + /** 945 + * Model used to test deduplication strategy (unused) 946 + */ 947 + export const zParameterSimpleParameterUnused = z.string(); 948 + 949 + /** 950 + * Model used to test deduplication strategy 951 + */ 952 + export const zPostServiceWithEmptyTagResponse = z.string(); 953 + 954 + /** 955 + * Model used to test deduplication strategy 956 + */ 957 + export const zPostServiceWithEmptyTagResponse2 = z.string(); 958 + 959 + /** 960 + * Model used to test deduplication strategy 961 + */ 962 + export const zDeleteFooData = z.string(); 963 + 964 + /** 965 + * Model used to test deduplication strategy 966 + */ 967 + export const zDeleteFooData2 = z.string(); 968 + 969 + export const zSchemaWithFormRestrictedKeys = z.object({ 970 + description: z.string().optional(), 971 + 'x-enum-descriptions': z.string().optional(), 972 + 'x-enum-varnames': z.string().optional(), 973 + 'x-enumNames': z.string().optional(), 974 + title: z.string().optional(), 975 + object: z.object({ 976 + description: z.string().optional(), 977 + 'x-enum-descriptions': z.string().optional(), 978 + 'x-enum-varnames': z.string().optional(), 979 + 'x-enumNames': z.string().optional(), 980 + title: z.string().optional() 981 + }).optional(), 982 + array: z.array(z.object({ 983 + description: z.string().optional(), 984 + 'x-enum-descriptions': z.string().optional(), 985 + 'x-enum-varnames': z.string().optional(), 986 + 'x-enumNames': z.string().optional(), 987 + title: z.string().optional() 988 + })).optional() 989 + }); 990 + 991 + /** 992 + * This schema was giving PascalCase transformations a hard time 993 + */ 994 + export const zIoK8sApimachineryPkgApisMetaV1Preconditions = z.object({ 995 + resourceVersion: z.string().optional(), 996 + uid: z.string().optional() 997 + }); 998 + 999 + /** 1000 + * This schema was giving PascalCase transformations a hard time 1001 + */ 1002 + export const zIoK8sApimachineryPkgApisMetaV1DeleteOptions = z.object({ 1003 + preconditions: zIoK8sApimachineryPkgApisMetaV1Preconditions.optional() 1004 + }); 1005 + 1006 + export const zAdditionalPropertiesUnknownIssue = z.object({}); 1007 + 1008 + export const zAdditionalPropertiesUnknownIssue2 = z.object({}); 1009 + 1010 + export const zAdditionalPropertiesUnknownIssue3 = z.intersection(z.string(), z.object({ 1011 + entries: z.object({}) 1012 + })); 1013 + 1014 + export const zAdditionalPropertiesIntegerIssue = z.object({ 1015 + value: z.number().int() 1016 + }); 1017 + 1018 + export const zGenericSchemaDuplicateIssue1SystemBoolean = z.object({ 1019 + item: z.boolean().optional(), 1020 + error: z.union([ 1021 + z.string(), 1022 + z.null() 1023 + ]).optional(), 1024 + hasError: z.boolean().readonly().optional(), 1025 + data: z.object({}).optional() 1026 + }); 1027 + 1028 + export const zGenericSchemaDuplicateIssue1SystemString = z.object({ 1029 + item: z.union([ 1030 + z.string(), 1031 + z.null() 1032 + ]).optional(), 1033 + error: z.union([ 1034 + z.string(), 1035 + z.null() 1036 + ]).optional(), 1037 + hasError: z.boolean().readonly().optional() 1038 + }); 1039 + 1040 + export const zOneOfAllOfIssue = z.union([ 1041 + z.intersection(z.union([ 1042 + zConstValue, 1043 + zGenericSchemaDuplicateIssue1SystemBoolean 1044 + ]), z3eNum1Период), 1045 + zGenericSchemaDuplicateIssue1SystemString 1046 + ]); 1047 + 1048 + /** 1049 + * Model with number-only name 1050 + */ 1051 + export const z400Writable = z.string(); 1052 + 1053 + /** 1054 + * Testing multiline comments in string: First line 1055 + * Second line 1056 + * 1057 + * Fourth line 1058 + */ 1059 + export const zCamelCaseCommentWithBreaksWritable = z.number().int(); 1060 + 1061 + /** 1062 + * Testing multiline comments in string: First line 1063 + * Second line 1064 + * 1065 + * Fourth line 1066 + */ 1067 + export const zCommentWithBreaksWritable = z.number().int(); 1068 + 1069 + /** 1070 + * Testing backticks in string: `backticks` and ```multiple backticks``` should work 1071 + */ 1072 + export const zCommentWithBackticksWritable = z.number().int(); 1073 + 1074 + /** 1075 + * Testing backticks and quotes in string: `backticks`, 'quotes', "double quotes" and ```multiple backticks``` should work 1076 + */ 1077 + export const zCommentWithBackticksAndQuotesWritable = z.number().int(); 1078 + 1079 + /** 1080 + * Testing slashes in string: \backwards\\\ and /forwards/// should work 1081 + */ 1082 + export const zCommentWithSlashesWritable = z.number().int(); 1083 + 1084 + /** 1085 + * Testing expression placeholders in string: ${expression} should work 1086 + */ 1087 + export const zCommentWithExpressionPlaceholdersWritable = z.number().int(); 1088 + 1089 + /** 1090 + * Testing quotes in string: 'single quote''' and "double quotes""" should work 1091 + */ 1092 + export const zCommentWithQuotesWritable = z.number().int(); 1093 + 1094 + /** 1095 + * Testing reserved characters in string: * inline * and ** inline ** should work 1096 + */ 1097 + export const zCommentWithReservedCharactersWritable = z.number().int(); 1098 + 1099 + /** 1100 + * This is a simple number 1101 + */ 1102 + export const zSimpleIntegerWritable = z.number().int(); 1103 + 1104 + /** 1105 + * This is a simple boolean 1106 + */ 1107 + export const zSimpleBooleanWritable = z.boolean(); 1108 + 1109 + /** 1110 + * This is a simple string 1111 + */ 1112 + export const zSimpleStringWritable = z.string(); 1113 + 1114 + /** 1115 + * A string with non-ascii (unicode) characters valid in typescript identifiers (æøåÆØÅöÔèÈ字符串) 1116 + */ 1117 + export const zNonAsciiStringæøåÆøÅöôêÊ字符串Writable = z.string(); 1118 + 1119 + /** 1120 + * This is a simple file 1121 + */ 1122 + export const zSimpleFileWritable = z.string(); 1123 + 1124 + /** 1125 + * This is a simple string 1126 + */ 1127 + export const zSimpleStringWithPatternWritable = z.union([ 1128 + z.string().max(64).regex(/^[a-zA-Z0-9_]*$/), 1129 + z.null() 1130 + ]); 1131 + 1132 + /** 1133 + * This is a simple enum with strings 1134 + */ 1135 + export const zEnumWithStringsWritable = z.enum([ 1136 + 'Success', 1137 + 'Warning', 1138 + 'Error', 1139 + "'Single Quote'", 1140 + '"Double Quotes"', 1141 + 'Non-ascii: øæåôöØÆÅÔÖ字符串' 1142 + ]); 1143 + 1144 + export const zEnumWithReplacedCharactersWritable = z.enum([ 1145 + "'Single Quote'", 1146 + '"Double Quotes"', 1147 + 'øæåôöØÆÅÔÖ字符串', 1148 + '' 1149 + ]); 1150 + 1151 + /** 1152 + * This is a simple enum with numbers 1153 + */ 1154 + export const zEnumWithNumbersWritable = z.unknown(); 1155 + 1156 + /** 1157 + * Success=1,Warning=2,Error=3 1158 + */ 1159 + export const zEnumFromDescriptionWritable = z.number(); 1160 + 1161 + /** 1162 + * This is a simple enum with numbers 1163 + */ 1164 + export const zEnumWithExtensionsWritable = z.unknown(); 1165 + 1166 + export const zEnumWithXEnumNamesWritable = z.unknown(); 1167 + 1168 + /** 1169 + * This is a simple array with numbers 1170 + */ 1171 + export const zArrayWithNumbersWritable = z.array(z.number().int()); 1172 + 1173 + /** 1174 + * This is a simple array with booleans 1175 + */ 1176 + export const zArrayWithBooleansWritable = z.array(z.boolean()); 1177 + 1178 + /** 1179 + * This is a simple array with strings 1180 + */ 1181 + export const zArrayWithStringsWritable = z.array(z.string()).default(['test']); 1182 + 1183 + /** 1184 + * This is a string dictionary 1185 + */ 1186 + export const zDictionaryWithStringWritable = z.object({}); 1187 + 1188 + /** 1189 + * This is a string dictionary 1190 + */ 1191 + export const zDictionaryWithDictionaryWritable = z.record(z.object({})); 1192 + 1193 + /** 1194 + * `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) 1195 + */ 1196 + export const zModelFromZendeskWritable = z.string(); 1197 + 1198 + export const zModelWithReadOnlyAndWriteOnlyWritable = z.object({ 1199 + foo: z.string(), 1200 + baz: z.string() 1201 + }); 1202 + 1203 + /** 1204 + * This is a model with one property containing an array 1205 + */ 1206 + export const zModelWithArrayReadOnlyAndWriteOnlyWritable = z.object({ 1207 + prop: z.array(zModelWithReadOnlyAndWriteOnlyWritable).optional(), 1208 + propWithFile: z.array(z.string()).optional(), 1209 + propWithNumber: z.array(z.number()).optional() 1210 + }); 1211 + 1212 + export const z3eNum1ПериодWritable = z.enum([ 1213 + 'Bird', 1214 + 'Dog' 1215 + ]); 1216 + 1217 + export const zConstValueWritable = z.literal('ConstValue'); 1218 + 1219 + /** 1220 + * This is a free-form object without additionalProperties. 1221 + */ 1222 + export const zFreeFormObjectWithoutAdditionalPropertiesWritable = z.object({}); 1223 + 1224 + /** 1225 + * This is a free-form object with additionalProperties: true. 1226 + */ 1227 + export const zFreeFormObjectWithAdditionalPropertiesEqTrueWritable = z.object({}); 1228 + 1229 + /** 1230 + * This is a free-form object with additionalProperties: {}. 1231 + */ 1232 + export const zFreeFormObjectWithAdditionalPropertiesEqEmptyObjectWritable = z.object({}); 1233 + 1234 + /** 1235 + * Some % character 1236 + */ 1237 + export const zCharactersInDescriptionWritable = z.string(); 1238 + 1239 + export const zModelWithNestedArrayEnumsDataFooWritable = z.enum([ 1240 + 'foo', 1241 + 'bar' 1242 + ]); 1243 + 1244 + export const zModelWithNestedArrayEnumsDataBarWritable = z.enum([ 1245 + 'baz', 1246 + 'qux' 1247 + ]); 1248 + 1249 + export const zModelWithConstantSizeArrayWritable = z.tuple([ 1250 + z.number(), 1251 + z.number() 1252 + ]); 1253 + 1254 + export const zModelWithAnyOfConstantSizeArrayWritable = z.tuple([ 1255 + z.union([ 1256 + z.number(), 1257 + z.string() 1258 + ]), 1259 + z.union([ 1260 + z.number(), 1261 + z.string() 1262 + ]), 1263 + z.union([ 1264 + z.number(), 1265 + z.string() 1266 + ]) 1267 + ]); 1268 + 1269 + export const zModelWithAnyOfConstantSizeArrayNullableWritable = z.tuple([ 1270 + z.union([ 1271 + z.number(), 1272 + z.null(), 1273 + z.string() 1274 + ]), 1275 + z.union([ 1276 + z.number(), 1277 + z.null(), 1278 + z.string() 1279 + ]), 1280 + z.union([ 1281 + z.number(), 1282 + z.null(), 1283 + z.string() 1284 + ]) 1285 + ]); 1286 + 1287 + /** 1288 + * Model with restricted keyword name 1289 + */ 1290 + export const zImportWritable = z.string(); 1291 + 1292 + export const zModelWithAnyOfConstantSizeArrayWithNSizeAndOptionsWritable = z.tuple([ 1293 + z.union([ 1294 + z.number(), 1295 + zImportWritable 1296 + ]), 1297 + z.union([ 1298 + z.number(), 1299 + zImportWritable 1300 + ]) 1301 + ]); 1302 + 1303 + export const zModelWithAnyOfConstantSizeArrayAndIntersectWritable = z.tuple([ 1304 + z.intersection(z.number(), z.string()), 1305 + z.intersection(z.number(), z.string()) 1306 + ]); 1307 + 1308 + /** 1309 + * Model used to test deduplication strategy (unused) 1310 + */ 1311 + export const zParameterSimpleParameterUnusedWritable = z.string(); 1312 + 1313 + /** 1314 + * Model used to test deduplication strategy 1315 + */ 1316 + export const zPostServiceWithEmptyTagResponseWritable = z.string(); 1317 + 1318 + /** 1319 + * Model used to test deduplication strategy 1320 + */ 1321 + export const zPostServiceWithEmptyTagResponse2Writable = z.string(); 1322 + 1323 + /** 1324 + * Model used to test deduplication strategy 1325 + */ 1326 + export const zDeleteFooDataWritable = z.string(); 1327 + 1328 + /** 1329 + * Model used to test deduplication strategy 1330 + */ 1331 + export const zDeleteFooData2Writable = z.string(); 1332 + 1333 + export const zAdditionalPropertiesUnknownIssueWritable = z.object({}); 1334 + 1335 + export const zAdditionalPropertiesUnknownIssue2Writable = z.object({}); 1336 + 1337 + export const zOneOfAllOfIssueWritable = z.union([ 1338 + z.intersection(z.union([ 1339 + zConstValueWritable, 1340 + zGenericSchemaDuplicateIssue1SystemBoolean 1341 + ]), z3eNum1Период), 1342 + zGenericSchemaDuplicateIssue1SystemString 1343 + ]); 1344 + 1345 + /** 1346 + * Parameter with illegal characters 1347 + */ 1348 + export const zXFooBar = zModelWithString; 1349 + 1350 + /** 1351 + * A reusable request body 1352 + */ 1353 + export const zSimpleRequestBody = zModelWithString; 1354 + 1355 + /** 1356 + * A reusable request body 1357 + */ 1358 + export const zSimpleFormData = zModelWithString; 1359 + 1360 + export const zExportData = z.object({ 1361 + body: z.never().optional(), 1362 + path: z.never().optional(), 1363 + query: z.never().optional() 1364 + }); 1365 + 1366 + export const zPatchApiVbyApiVersionNoTagData = z.object({ 1367 + body: z.never().optional(), 1368 + path: z.never().optional(), 1369 + query: z.never().optional() 1370 + }); 1371 + 1372 + export const zImportData = z.object({ 1373 + body: z.union([ 1374 + zModelWithReadOnlyAndWriteOnlyWritable, 1375 + zModelWithArrayReadOnlyAndWriteOnlyWritable 1376 + ]), 1377 + path: z.never().optional(), 1378 + query: z.never().optional() 1379 + }); 1380 + 1381 + export const zImportResponse = z.union([ 1382 + zModelFromZendesk, 1383 + zModelWithReadOnlyAndWriteOnly 1384 + ]); 1385 + 1386 + export const zFooWowData = z.object({ 1387 + body: z.never().optional(), 1388 + path: z.never().optional(), 1389 + query: z.never().optional() 1390 + }); 1391 + 1392 + export const zApiVVersionODataControllerCountData = z.object({ 1393 + body: z.never().optional(), 1394 + path: z.never().optional(), 1395 + query: z.never().optional() 1396 + }); 1397 + 1398 + /** 1399 + * Success 1400 + */ 1401 + export const zApiVVersionODataControllerCountResponse = zModelFromZendesk; 1402 + 1403 + export const zGetApiVbyApiVersionSimpleOperationData = z.object({ 1404 + body: z.never().optional(), 1405 + path: z.object({ 1406 + foo_param: z.union([ 1407 + z.string(), 1408 + z.string().uuid() 1409 + ]) 1410 + }), 1411 + query: z.never().optional() 1412 + }); 1413 + 1414 + /** 1415 + * Response is a simple number 1416 + */ 1417 + export const zGetApiVbyApiVersionSimpleOperationResponse = z.number(); 1418 + 1419 + export const zDeleteCallWithoutParametersAndResponseData = z.object({ 1420 + body: z.never().optional(), 1421 + path: z.never().optional(), 1422 + query: z.never().optional() 1423 + }); 1424 + 1425 + export const zGetCallWithoutParametersAndResponseData = z.object({ 1426 + body: z.never().optional(), 1427 + path: z.never().optional(), 1428 + query: z.never().optional() 1429 + }); 1430 + 1431 + export const zHeadCallWithoutParametersAndResponseData = z.object({ 1432 + body: z.never().optional(), 1433 + path: z.never().optional(), 1434 + query: z.never().optional() 1435 + }); 1436 + 1437 + export const zOptionsCallWithoutParametersAndResponseData = z.object({ 1438 + body: z.never().optional(), 1439 + path: z.never().optional(), 1440 + query: z.never().optional() 1441 + }); 1442 + 1443 + export const zPatchCallWithoutParametersAndResponseData = z.object({ 1444 + body: z.never().optional(), 1445 + path: z.never().optional(), 1446 + query: z.never().optional() 1447 + }); 1448 + 1449 + export const zPostCallWithoutParametersAndResponseData = z.object({ 1450 + body: z.never().optional(), 1451 + path: z.never().optional(), 1452 + query: z.never().optional() 1453 + }); 1454 + 1455 + export const zPutCallWithoutParametersAndResponseData = z.object({ 1456 + body: z.never().optional(), 1457 + path: z.never().optional(), 1458 + query: z.never().optional() 1459 + }); 1460 + 1461 + export const zDeleteFooData3 = z.object({ 1462 + body: z.never().optional(), 1463 + path: z.object({ 1464 + foo_param: z.string(), 1465 + BarParam: z.string() 1466 + }), 1467 + query: z.never().optional(), 1468 + headers: z.object({ 1469 + 'x-Foo-Bar': zModelWithString 1470 + }) 1471 + }); 1472 + 1473 + export const zCallWithDescriptionsData = z.object({ 1474 + body: z.never().optional(), 1475 + path: z.never().optional(), 1476 + query: z.object({ 1477 + parameterWithBreaks: z.string().optional(), 1478 + parameterWithBackticks: z.string().optional(), 1479 + parameterWithSlashes: z.string().optional(), 1480 + parameterWithExpressionPlaceholders: z.string().optional(), 1481 + parameterWithQuotes: z.string().optional(), 1482 + parameterWithReservedCharacters: z.string().optional() 1483 + }).optional() 1484 + }); 1485 + 1486 + export const zDeprecatedCallData = z.object({ 1487 + body: z.never().optional(), 1488 + path: z.never().optional(), 1489 + query: z.never().optional(), 1490 + headers: z.object({ 1491 + parameter: z.union([ 1492 + zDeprecatedModel, 1493 + z.null() 1494 + ]) 1495 + }) 1496 + }); 1497 + 1498 + export const zCallWithParametersData = z.object({ 1499 + body: z.union([ 1500 + z.object({}), 1501 + z.null() 1502 + ]), 1503 + path: z.object({ 1504 + parameterPath: z.union([ 1505 + z.string(), 1506 + z.null() 1507 + ]), 1508 + 'api-version': z.union([ 1509 + z.string(), 1510 + z.null() 1511 + ]) 1512 + }), 1513 + query: z.object({ 1514 + foo_ref_enum: zModelWithNestedArrayEnumsDataFooWritable.optional(), 1515 + foo_all_of_enum: zModelWithNestedArrayEnumsDataFooWritable, 1516 + cursor: z.union([ 1517 + z.string(), 1518 + z.null() 1519 + ]) 1520 + }), 1521 + headers: z.object({ 1522 + parameterHeader: z.union([ 1523 + z.string(), 1524 + z.null() 1525 + ]) 1526 + }) 1527 + }); 1528 + 1529 + export const zCallWithWeirdParameterNamesData = z.object({ 1530 + body: z.union([ 1531 + zModelWithString, 1532 + z.null() 1533 + ]), 1534 + path: z.object({ 1535 + 'parameter.path.1': z.string().optional(), 1536 + 'parameter-path-2': z.string().optional(), 1537 + 'PARAMETER-PATH-3': z.string().optional(), 1538 + 'api-version': z.union([ 1539 + z.string(), 1540 + z.null() 1541 + ]) 1542 + }), 1543 + query: z.object({ 1544 + default: z.string().optional(), 1545 + 'parameter-query': z.union([ 1546 + z.string(), 1547 + z.null() 1548 + ]) 1549 + }), 1550 + headers: z.object({ 1551 + 'parameter.header': z.union([ 1552 + z.string(), 1553 + z.null() 1554 + ]) 1555 + }) 1556 + }); 1557 + 1558 + export const zGetCallWithOptionalParamData = z.object({ 1559 + body: zModelWithOneOfEnum, 1560 + path: z.never().optional(), 1561 + query: z.object({ 1562 + page: z.number().optional() 1563 + }).optional() 1564 + }); 1565 + 1566 + export const zPostCallWithOptionalParamData = z.object({ 1567 + body: z.object({ 1568 + offset: z.union([ 1569 + z.number(), 1570 + z.null() 1571 + ]).optional() 1572 + }).optional(), 1573 + path: z.never().optional(), 1574 + query: z.object({ 1575 + parameter: zPageable 1576 + }) 1577 + }); 1578 + 1579 + export const zPostCallWithOptionalParamResponse = z.union([ 1580 + z.number(), 1581 + z.void() 1582 + ]); 1583 + 1584 + export const zPostApiVbyApiVersionRequestBodyData = z.object({ 1585 + body: zSimpleRequestBody.optional(), 1586 + path: z.never().optional(), 1587 + query: z.object({ 1588 + parameter: z.string().optional() 1589 + }).optional() 1590 + }); 1591 + 1592 + export const zPostApiVbyApiVersionFormDataData = z.object({ 1593 + body: zSimpleFormData.optional(), 1594 + path: z.never().optional(), 1595 + query: z.object({ 1596 + parameter: z.string().optional() 1597 + }).optional() 1598 + }); 1599 + 1600 + export const zCallWithDefaultParametersData = z.object({ 1601 + body: z.never().optional(), 1602 + path: z.never().optional(), 1603 + query: z.object({ 1604 + parameterString: z.union([ 1605 + z.string().default('Hello World!'), 1606 + z.null() 1607 + ]).optional().default('Hello World!'), 1608 + parameterNumber: z.union([ 1609 + z.number().default(123), 1610 + z.null() 1611 + ]).optional().default(123), 1612 + parameterBoolean: z.union([ 1613 + z.boolean().default(true), 1614 + z.null() 1615 + ]).optional().default(true), 1616 + parameterEnum: z.enum([ 1617 + 'Success', 1618 + 'Warning', 1619 + 'Error' 1620 + ]).optional(), 1621 + parameterModel: z.union([ 1622 + zModelWithString, 1623 + z.null() 1624 + ]).optional() 1625 + }).optional() 1626 + }); 1627 + 1628 + export const zCallWithDefaultOptionalParametersData = z.object({ 1629 + body: z.never().optional(), 1630 + path: z.never().optional(), 1631 + query: z.object({ 1632 + parameterString: z.string().optional().default('Hello World!'), 1633 + parameterNumber: z.number().optional().default(123), 1634 + parameterBoolean: z.boolean().optional().default(true), 1635 + parameterEnum: z.enum([ 1636 + 'Success', 1637 + 'Warning', 1638 + 'Error' 1639 + ]).optional(), 1640 + parameterModel: zModelWithString.optional() 1641 + }).optional() 1642 + }); 1643 + 1644 + export const zCallToTestOrderOfParamsData = z.object({ 1645 + body: z.never().optional(), 1646 + path: z.never().optional(), 1647 + query: z.object({ 1648 + parameterOptionalStringWithDefault: z.string().optional().default('Hello World!'), 1649 + parameterOptionalStringWithEmptyDefault: z.string().optional().default(''), 1650 + parameterOptionalStringWithNoDefault: z.string().optional(), 1651 + parameterStringWithDefault: z.string().default('Hello World!'), 1652 + parameterStringWithEmptyDefault: z.string().default(''), 1653 + parameterStringWithNoDefault: z.string(), 1654 + parameterStringNullableWithNoDefault: z.union([ 1655 + z.string(), 1656 + z.null() 1657 + ]).optional(), 1658 + parameterStringNullableWithDefault: z.union([ 1659 + z.string(), 1660 + z.null() 1661 + ]).optional().default(null) 1662 + }) 1663 + }); 1664 + 1665 + export const zDuplicateNameData = z.object({ 1666 + body: z.never().optional(), 1667 + path: z.never().optional(), 1668 + query: z.never().optional() 1669 + }); 1670 + 1671 + export const zDuplicateName2Data = z.object({ 1672 + body: z.never().optional(), 1673 + path: z.never().optional(), 1674 + query: z.never().optional() 1675 + }); 1676 + 1677 + export const zDuplicateName3Data = z.object({ 1678 + body: z.never().optional(), 1679 + path: z.never().optional(), 1680 + query: z.never().optional() 1681 + }); 1682 + 1683 + export const zDuplicateName4Data = z.object({ 1684 + body: z.never().optional(), 1685 + path: z.never().optional(), 1686 + query: z.never().optional() 1687 + }); 1688 + 1689 + export const zCallWithNoContentResponseData = z.object({ 1690 + body: z.never().optional(), 1691 + path: z.never().optional(), 1692 + query: z.never().optional() 1693 + }); 1694 + 1695 + /** 1696 + * Success 1697 + */ 1698 + export const zCallWithNoContentResponseResponse = z.void(); 1699 + 1700 + export const zCallWithResponseAndNoContentResponseData = z.object({ 1701 + body: z.never().optional(), 1702 + path: z.never().optional(), 1703 + query: z.never().optional() 1704 + }); 1705 + 1706 + export const zCallWithResponseAndNoContentResponseResponse = z.union([ 1707 + z.number(), 1708 + z.void() 1709 + ]); 1710 + 1711 + export const zDummyAData = z.object({ 1712 + body: z.never().optional(), 1713 + path: z.never().optional(), 1714 + query: z.never().optional() 1715 + }); 1716 + 1717 + export const zDummyAResponse = z400; 1718 + 1719 + export const zDummyBData = z.object({ 1720 + body: z.never().optional(), 1721 + path: z.never().optional(), 1722 + query: z.never().optional() 1723 + }); 1724 + 1725 + /** 1726 + * Success 1727 + */ 1728 + export const zDummyBResponse = z.void(); 1729 + 1730 + export const zCallWithResponseData = z.object({ 1731 + body: z.never().optional(), 1732 + path: z.never().optional(), 1733 + query: z.never().optional() 1734 + }); 1735 + 1736 + export const zCallWithResponseResponse = zImport; 1737 + 1738 + export const zCallWithDuplicateResponsesData = z.object({ 1739 + body: z.never().optional(), 1740 + path: z.never().optional(), 1741 + query: z.never().optional() 1742 + }); 1743 + 1744 + export const zCallWithDuplicateResponsesResponse = z.union([ 1745 + zModelWithBoolean.and(zModelWithInteger), 1746 + zModelWithString 1747 + ]); 1748 + 1749 + export const zCallWithResponsesData = z.object({ 1750 + body: z.never().optional(), 1751 + path: z.never().optional(), 1752 + query: z.never().optional() 1753 + }); 1754 + 1755 + export const zCallWithResponsesResponse = z.union([ 1756 + z.object({ 1757 + '@namespace.string': z.string().readonly().optional(), 1758 + '@namespace.integer': z.number().int().readonly().optional(), 1759 + value: z.array(zModelWithString).readonly().optional() 1760 + }), 1761 + zModelThatExtends, 1762 + zModelThatExtendsExtends 1763 + ]); 1764 + 1765 + export const zCollectionFormatData = z.object({ 1766 + body: z.never().optional(), 1767 + path: z.never().optional(), 1768 + query: z.object({ 1769 + parameterArrayCSV: z.union([ 1770 + z.array(z.string()), 1771 + z.null() 1772 + ]), 1773 + parameterArraySSV: z.union([ 1774 + z.array(z.string()), 1775 + z.null() 1776 + ]), 1777 + parameterArrayTSV: z.union([ 1778 + z.array(z.string()), 1779 + z.null() 1780 + ]), 1781 + parameterArrayPipes: z.union([ 1782 + z.array(z.string()), 1783 + z.null() 1784 + ]), 1785 + parameterArrayMulti: z.union([ 1786 + z.array(z.string()), 1787 + z.null() 1788 + ]) 1789 + }) 1790 + }); 1791 + 1792 + export const zTypesData = z.object({ 1793 + body: z.never().optional(), 1794 + path: z.object({ 1795 + id: z.number().int().optional() 1796 + }).optional(), 1797 + query: z.object({ 1798 + parameterNumber: z.number().default(123), 1799 + parameterString: z.union([ 1800 + z.string().default('default'), 1801 + z.null() 1802 + ]).default('default'), 1803 + parameterBoolean: z.union([ 1804 + z.boolean().default(true), 1805 + z.null() 1806 + ]).default(true), 1807 + parameterObject: z.union([ 1808 + z.object({}), 1809 + z.null() 1810 + ]).default(null), 1811 + parameterArray: z.union([ 1812 + z.array(z.string()), 1813 + z.null() 1814 + ]), 1815 + parameterDictionary: z.union([ 1816 + z.object({}), 1817 + z.null() 1818 + ]), 1819 + parameterEnum: z.union([ 1820 + z.literal('Success'), 1821 + z.literal('Warning'), 1822 + z.literal('Error'), 1823 + z.null() 1824 + ]) 1825 + }) 1826 + }); 1827 + 1828 + export const zTypesResponse = z.union([ 1829 + z.number(), 1830 + z.string(), 1831 + z.boolean(), 1832 + z.object({}) 1833 + ]); 1834 + 1835 + export const zUploadFileData = z.object({ 1836 + body: z.string(), 1837 + path: z.object({ 1838 + 'api-version': z.union([ 1839 + z.string(), 1840 + z.null() 1841 + ]) 1842 + }), 1843 + query: z.never().optional() 1844 + }); 1845 + 1846 + export const zUploadFileResponse = z.boolean(); 1847 + 1848 + export const zFileResponseData = z.object({ 1849 + body: z.never().optional(), 1850 + path: z.object({ 1851 + id: z.string(), 1852 + 'api-version': z.string() 1853 + }), 1854 + query: z.never().optional() 1855 + }); 1856 + 1857 + /** 1858 + * Success 1859 + */ 1860 + export const zFileResponseResponse = z.string(); 1861 + 1862 + export const zComplexTypesData = z.object({ 1863 + body: z.never().optional(), 1864 + path: z.never().optional(), 1865 + query: z.object({ 1866 + parameterObject: z.object({ 1867 + first: z.object({ 1868 + second: z.object({ 1869 + third: z.string().optional() 1870 + }).optional() 1871 + }).optional() 1872 + }), 1873 + parameterReference: zModelWithString 1874 + }) 1875 + }); 1876 + 1877 + /** 1878 + * Successful response 1879 + */ 1880 + export const zComplexTypesResponse = z.array(zModelWithString); 1881 + 1882 + export const zMultipartResponseData = z.object({ 1883 + body: z.never().optional(), 1884 + path: z.never().optional(), 1885 + query: z.never().optional() 1886 + }); 1887 + 1888 + /** 1889 + * OK 1890 + */ 1891 + export const zMultipartResponseResponse = z.object({ 1892 + file: z.string().optional(), 1893 + metadata: z.object({ 1894 + foo: z.string().optional(), 1895 + bar: z.string().optional() 1896 + }).optional() 1897 + }); 1898 + 1899 + export const zMultipartRequestData = z.object({ 1900 + body: z.object({ 1901 + content: z.string().optional(), 1902 + data: z.union([ 1903 + zModelWithString, 1904 + z.null() 1905 + ]).optional() 1906 + }).optional(), 1907 + path: z.never().optional(), 1908 + query: z.never().optional() 1909 + }); 1910 + 1911 + export const zComplexParamsData = z.object({ 1912 + body: z.object({ 1913 + key: z.union([ 1914 + z.string().max(64).regex(/^[a-zA-Z0-9_]*$/).readonly(), 1915 + z.null() 1916 + ]).readonly(), 1917 + name: z.union([ 1918 + z.string().max(255), 1919 + z.null() 1920 + ]), 1921 + enabled: z.boolean().optional().default(true), 1922 + type: z.enum([ 1923 + 'Monkey', 1924 + 'Horse', 1925 + 'Bird' 1926 + ]), 1927 + listOfModels: z.union([ 1928 + z.array(zModelWithString), 1929 + z.null() 1930 + ]).optional(), 1931 + listOfStrings: z.union([ 1932 + z.array(z.string()), 1933 + z.null() 1934 + ]).optional(), 1935 + parameters: z.union([ 1936 + zModelWithString, 1937 + zModelWithEnum, 1938 + zModelWithArray, 1939 + zModelWithDictionary 1940 + ]), 1941 + user: z.object({ 1942 + id: z.number().int().readonly().optional(), 1943 + name: z.union([ 1944 + z.string().readonly(), 1945 + z.null() 1946 + ]).readonly().optional() 1947 + }).readonly().optional() 1948 + }).optional(), 1949 + path: z.object({ 1950 + id: z.number().int(), 1951 + 'api-version': z.string() 1952 + }), 1953 + query: z.never().optional() 1954 + }); 1955 + 1956 + /** 1957 + * Success 1958 + */ 1959 + export const zComplexParamsResponse = zModelWithString; 1960 + 1961 + export const zCallWithResultFromHeaderData = z.object({ 1962 + body: z.never().optional(), 1963 + path: z.never().optional(), 1964 + query: z.never().optional() 1965 + }); 1966 + 1967 + export const zTestErrorCodeData = z.object({ 1968 + body: z.never().optional(), 1969 + path: z.never().optional(), 1970 + query: z.object({ 1971 + status: z.number().int() 1972 + }) 1973 + }); 1974 + 1975 + export const zNonAsciiæøåÆøÅöôêÊ字符串Data = z.object({ 1976 + body: z.never().optional(), 1977 + path: z.never().optional(), 1978 + query: z.object({ 1979 + 'nonAsciiParamæøåÆØÅöôêÊ': z.number().int() 1980 + }) 1981 + }); 1982 + 1983 + /** 1984 + * Successful response 1985 + */ 1986 + export const zNonAsciiæøåÆøÅöôêÊ字符串Response = z.array(zNonAsciiStringæøåÆøÅöôêÊ字符串); 1987 + 1988 + export const zPutWithFormUrlEncodedData = z.object({ 1989 + body: zArrayWithStringsWritable, 1990 + path: z.never().optional(), 1991 + query: z.never().optional() 1992 + });
+19
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/schema-const/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod/v3'; 4 + 5 + export const zFoo = z.object({ 6 + foo: z.literal('foo').optional(), 7 + bar: z.literal(3.2).optional(), 8 + baz: z.literal(-1).optional(), 9 + qux: z.literal(true).optional(), 10 + quux: z.tuple([ 11 + z.literal(1), 12 + z.literal(2), 13 + z.literal(3), 14 + z.literal('foo'), 15 + z.literal(true) 16 + ]).optional(), 17 + corge: z.object({}).optional(), 18 + garply: z.coerce.bigint().optional() 19 + });
+24
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/type-format-zod/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod/v3'; 4 + 5 + export const zFoo = z.object({ 6 + bar: z.number().int().optional(), 7 + foo: z.coerce.bigint().default(BigInt(0)), 8 + id: z.string() 9 + }); 10 + 11 + export const zBar = z.object({ 12 + foo: z.number().int() 13 + }); 14 + 15 + export const zPostFooData = z.object({ 16 + body: z.never().optional(), 17 + path: z.never().optional(), 18 + query: z.never().optional() 19 + }); 20 + 21 + /** 22 + * OK 23 + */ 24 + export const zPostFooResponse = zFoo;
+7
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-bigint-min-max/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod/v3'; 4 + 5 + export const zFoo = z.object({ 6 + foo: z.coerce.bigint().gte(BigInt(0)).lte(BigInt(100)).optional() 7 + });
+16
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-circular-ref-2/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod/v3'; 4 + 5 + export const zBar: z.AnyZodObject = z.object({ 6 + bar: z.union([ 7 + z.array(z.lazy(() => { 8 + return zBar; 9 + })), 10 + z.null() 11 + ]) 12 + }); 13 + 14 + export const zFoo: z.AnyZodObject = z.object({ 15 + foo: zBar 16 + });
+22
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-circular-ref/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod/v3'; 4 + 5 + export const zBar: z.AnyZodObject = z.object({ 6 + bar: z.array(z.lazy(() => { 7 + return zBar; 8 + })).optional() 9 + }); 10 + 11 + export const zFoo: z.AnyZodObject = z.object({ 12 + foo: zBar.optional() 13 + }); 14 + 15 + /** 16 + * description caused circular reference error 17 + */ 18 + export const zQux: z.ZodTypeAny = z.lazy(() => { 19 + return zQux; 20 + }); 21 + 22 + export const zBaz: z.ZodTypeAny = zQux;
+66
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-dates/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod/v3'; 4 + 5 + /** 6 + * This is Bar schema. 7 + */ 8 + export const zBar: z.AnyZodObject = z.object({ 9 + foo: z.lazy(() => { 10 + return zFoo; 11 + }).optional() 12 + }); 13 + 14 + /** 15 + * This is Foo schema. 16 + */ 17 + export const zFoo: z.ZodTypeAny = z.union([ 18 + z.object({ 19 + foo: z.string().regex(/^\d{3}-\d{2}-\d{4}$/).optional(), 20 + bar: zBar.optional(), 21 + baz: z.array(z.lazy(() => { 22 + return zFoo; 23 + })).optional(), 24 + qux: z.number().int().gt(0).optional().default(0) 25 + }), 26 + z.null() 27 + ]).default(null); 28 + 29 + export const zBaz = z.string().regex(/foo\nbar/).readonly().default('baz'); 30 + 31 + export const zQux = z.record(z.object({ 32 + qux: z.string().optional() 33 + })); 34 + 35 + /** 36 + * This is Foo parameter. 37 + */ 38 + export const zFoo2 = z.string(); 39 + 40 + export const zFoo3 = z.object({ 41 + foo: zBar.optional() 42 + }); 43 + 44 + export const zPatchFooData = z.object({ 45 + body: z.object({ 46 + foo: z.string().optional() 47 + }), 48 + path: z.never().optional(), 49 + query: z.object({ 50 + foo: z.string().optional(), 51 + bar: zBar.optional(), 52 + baz: z.object({ 53 + baz: z.string().optional() 54 + }).optional(), 55 + qux: z.string().date().optional(), 56 + quux: z.string().datetime({ 57 + offset: true 58 + }).optional() 59 + }).optional() 60 + }); 61 + 62 + export const zPostFooData = z.object({ 63 + body: zFoo3, 64 + path: z.never().optional(), 65 + query: z.never().optional() 66 + });
+64
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-metadata/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod/v3'; 4 + 5 + /** 6 + * This is Bar schema. 7 + */ 8 + export const zBar: z.AnyZodObject = z.object({ 9 + foo: z.lazy(() => { 10 + return zFoo; 11 + }).optional() 12 + }).describe('This is Bar schema.'); 13 + 14 + /** 15 + * This is Foo schema. 16 + */ 17 + export const zFoo: z.ZodTypeAny = z.union([ 18 + z.object({ 19 + foo: z.string().regex(/^\d{3}-\d{2}-\d{4}$/).describe('This is foo property.').optional(), 20 + bar: zBar.optional(), 21 + baz: z.array(z.lazy(() => { 22 + return zFoo; 23 + })).describe('This is baz property.').optional(), 24 + qux: z.number().int().gt(0).describe('This is qux property.').optional().default(0) 25 + }), 26 + z.null() 27 + ]).default(null); 28 + 29 + export const zBaz = z.string().regex(/foo\nbar/).readonly().default('baz'); 30 + 31 + export const zQux = z.record(z.object({ 32 + qux: z.string().optional() 33 + })); 34 + 35 + /** 36 + * This is Foo parameter. 37 + */ 38 + export const zFoo2 = z.string().describe('This is Foo parameter.'); 39 + 40 + export const zFoo3 = z.object({ 41 + foo: zBar.optional() 42 + }); 43 + 44 + export const zPatchFooData = z.object({ 45 + body: z.object({ 46 + foo: z.string().optional() 47 + }), 48 + path: z.never().optional(), 49 + query: z.object({ 50 + foo: z.string().describe('This is Foo parameter.').optional(), 51 + bar: zBar.optional(), 52 + baz: z.object({ 53 + baz: z.string().optional() 54 + }).optional(), 55 + qux: z.string().date().optional(), 56 + quux: z.string().datetime().optional() 57 + }).optional() 58 + }); 59 + 60 + export const zPostFooData = z.object({ 61 + body: zFoo3, 62 + path: z.never().optional(), 63 + query: z.never().optional() 64 + });
+80
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-types/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod/v3'; 4 + 5 + /** 6 + * This is Bar schema. 7 + */ 8 + export const zBar: z.AnyZodObject = z.object({ 9 + foo: z.lazy(() => { 10 + return zFoo; 11 + }).optional() 12 + }); 13 + 14 + export type BarZodType = z.infer<typeof zBar>; 15 + 16 + /** 17 + * This is Foo schema. 18 + */ 19 + export const zFoo: z.ZodTypeAny = z.union([ 20 + z.object({ 21 + foo: z.string().regex(/^\d{3}-\d{2}-\d{4}$/).optional(), 22 + bar: zBar.optional(), 23 + baz: z.array(z.lazy(() => { 24 + return zFoo; 25 + })).optional(), 26 + qux: z.number().int().gt(0).optional().default(0) 27 + }), 28 + z.null() 29 + ]).default(null); 30 + 31 + export type FooZodType = z.infer<typeof zFoo>; 32 + 33 + export const zBaz = z.string().regex(/foo\nbar/).readonly().default('baz'); 34 + 35 + export type BazZodType = z.infer<typeof zBaz>; 36 + 37 + export const zQux = z.record(z.object({ 38 + qux: z.string().optional() 39 + })); 40 + 41 + export type QuxZodType = z.infer<typeof zQux>; 42 + 43 + /** 44 + * This is Foo parameter. 45 + */ 46 + export const zFoo2 = z.string(); 47 + 48 + export type FooZodType2 = z.infer<typeof zFoo2>; 49 + 50 + export const zFoo3 = z.object({ 51 + foo: zBar.optional() 52 + }); 53 + 54 + export type FooZodType3 = z.infer<typeof zFoo3>; 55 + 56 + export const zPatchFooData = z.object({ 57 + body: z.object({ 58 + foo: z.string().optional() 59 + }), 60 + path: z.never().optional(), 61 + query: z.object({ 62 + foo: z.string().optional(), 63 + bar: zBar.optional(), 64 + baz: z.object({ 65 + baz: z.string().optional() 66 + }).optional(), 67 + qux: z.string().date().optional(), 68 + quux: z.string().datetime().optional() 69 + }).optional() 70 + }); 71 + 72 + export type PatchFooDataZodType = z.infer<typeof zPatchFooData>; 73 + 74 + export const zPostFooData = z.object({ 75 + body: zFoo3, 76 + path: z.never().optional(), 77 + query: z.never().optional() 78 + }); 79 + 80 + export type PostFooDataZodType = z.infer<typeof zPostFooData>;
+44
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators-union-merge/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod/v3'; 4 + 5 + export const zContact = z.union([ 6 + z.object({ 7 + email: z.string() 8 + }), 9 + z.object({ 10 + phone: z.string() 11 + }) 12 + ]); 13 + 14 + export const zUser = zContact.and(z.object({ 15 + username: z.string() 16 + })); 17 + 18 + export const zDogDetails = z.object({ 19 + breed: z.string(), 20 + barkVolume: z.number().int().gte(1).lte(10) 21 + }); 22 + 23 + export const zCatDetails = z.object({ 24 + furLength: z.enum([ 25 + 'short', 26 + 'medium', 27 + 'long' 28 + ]), 29 + purrs: z.boolean() 30 + }); 31 + 32 + export const zPetStore = z.object({ 33 + animals: z.array(z.object({ 34 + name: z.string(), 35 + type: z.enum([ 36 + 'dog', 37 + 'cat' 38 + ]).optional(), 39 + details: z.union([ 40 + zDogDetails, 41 + zCatDetails 42 + ]) 43 + })) 44 + });
+64
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v3/validators/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod/v3'; 4 + 5 + /** 6 + * This is Bar schema. 7 + */ 8 + export const zBar: z.AnyZodObject = z.object({ 9 + foo: z.lazy(() => { 10 + return zFoo; 11 + }).optional() 12 + }); 13 + 14 + /** 15 + * This is Foo schema. 16 + */ 17 + export const zFoo: z.ZodTypeAny = z.union([ 18 + z.object({ 19 + foo: z.string().regex(/^\d{3}-\d{2}-\d{4}$/).optional(), 20 + bar: zBar.optional(), 21 + baz: z.array(z.lazy(() => { 22 + return zFoo; 23 + })).optional(), 24 + qux: z.number().int().gt(0).optional().default(0) 25 + }), 26 + z.null() 27 + ]).default(null); 28 + 29 + export const zBaz = z.string().regex(/foo\nbar/).readonly().default('baz'); 30 + 31 + export const zQux = z.record(z.object({ 32 + qux: z.string().optional() 33 + })); 34 + 35 + /** 36 + * This is Foo parameter. 37 + */ 38 + export const zFoo2 = z.string(); 39 + 40 + export const zFoo3 = z.object({ 41 + foo: zBar.optional() 42 + }); 43 + 44 + export const zPatchFooData = z.object({ 45 + body: z.object({ 46 + foo: z.string().optional() 47 + }), 48 + path: z.never().optional(), 49 + query: z.object({ 50 + foo: z.string().optional(), 51 + bar: zBar.optional(), 52 + baz: z.object({ 53 + baz: z.string().optional() 54 + }).optional(), 55 + qux: z.string().date().optional(), 56 + quux: z.string().datetime().optional() 57 + }).optional() 58 + }); 59 + 60 + export const zPostFooData = z.object({ 61 + body: zFoo3, 62 + path: z.never().optional(), 63 + query: z.never().optional() 64 + });
+18
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/enum-null/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod'; 4 + 5 + export const zFoo = z.nullable(z.enum([ 6 + 'foo', 7 + 'bar' 8 + ])); 9 + 10 + export const zBar = z.enum([ 11 + 'foo', 12 + 'bar' 13 + ]); 14 + 15 + export const zBaz = z.enum([ 16 + 'foo', 17 + 'bar' 18 + ]);
+24
packages/openapi-ts-tests/zod/v4/__snapshots__/3.1.x/v4/type-format-zod/zod.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { z } from 'zod'; 4 + 5 + export const zFoo = z.object({ 6 + bar: z.optional(z.int()), 7 + foo: z.coerce.bigint().default(BigInt(0)), 8 + id: z.string() 9 + }); 10 + 11 + export const zBar = z.object({ 12 + foo: z.int() 13 + }); 14 + 15 + export const zPostFooData = z.object({ 16 + body: z.optional(z.never()), 17 + path: z.optional(z.never()), 18 + query: z.optional(z.never()) 19 + }); 20 + 21 + /** 22 + * OK 23 + */ 24 + export const zPostFooResponse = zFoo;
+25
packages/openapi-ts-tests/zod/v4/package.json
··· 1 + { 2 + "name": "@test/openapi-ts-zod-v4", 3 + "version": "0.0.0", 4 + "private": true, 5 + "type": "module", 6 + "scripts": { 7 + "test:coverage": "vitest run --coverage", 8 + "test:update": "vitest watch --update", 9 + "test:watch": "vitest watch", 10 + "test": "vitest run", 11 + "typecheck": "tsc --noEmit" 12 + }, 13 + "engines": { 14 + "node": "^18.18.0 || ^20.9.0 || >=22.10.0" 15 + }, 16 + "peerDependencies": { 17 + "typescript": "^5.5.3" 18 + }, 19 + "devDependencies": { 20 + "@config/vite-base": "workspace:*", 21 + "@hey-api/openapi-ts": "workspace:*", 22 + "typescript": "5.8.3", 23 + "zod": "4.0.5" 24 + } 25 + }
+78
packages/openapi-ts-tests/zod/v4/test/3.0.x.test.ts
··· 1 + import fs from 'node:fs'; 2 + import path from 'node:path'; 3 + 4 + import { createClient } from '@hey-api/openapi-ts'; 5 + import { describe, expect, it } from 'vitest'; 6 + 7 + import { getFilePaths } from '../../../utils'; 8 + import { 9 + createZodConfig, 10 + getSnapshotsPath, 11 + getTempSnapshotsPath, 12 + zodVersions, 13 + } from './utils'; 14 + 15 + const version = '3.0.x'; 16 + 17 + for (const zodVersion of zodVersions) { 18 + const outputDir = path.join( 19 + getTempSnapshotsPath(), 20 + version, 21 + zodVersion.folder, 22 + ); 23 + const snapshotsDir = path.join( 24 + getSnapshotsPath(), 25 + version, 26 + zodVersion.folder, 27 + ); 28 + 29 + describe(`OpenAPI ${version}`, () => { 30 + const createConfig = createZodConfig({ 31 + openApiVersion: version, 32 + outputDir, 33 + zodVersion, 34 + }); 35 + 36 + const scenarios = [ 37 + { 38 + config: createConfig({ 39 + input: 'array-items-one-of-length-1.yaml', 40 + output: 'array-items-one-of-length-1', 41 + }), 42 + description: 43 + 'generates correct array when items are oneOf array with single item', 44 + }, 45 + { 46 + config: createConfig({ 47 + input: 'enum-null.json', 48 + output: 'enum-null', 49 + }), 50 + description: 'handles null enums', 51 + }, 52 + { 53 + config: createConfig({ 54 + input: 'validators.json', 55 + output: 'validators', 56 + }), 57 + description: 'generates validator schemas', 58 + }, 59 + ]; 60 + 61 + it.each(scenarios)('$description', async ({ config }) => { 62 + await createClient(config); 63 + 64 + const outputPath = 65 + typeof config.output === 'string' ? config.output : config.output.path; 66 + const filePaths = getFilePaths(outputPath); 67 + 68 + await Promise.all( 69 + filePaths.map(async (filePath) => { 70 + const fileContent = fs.readFileSync(filePath, 'utf-8'); 71 + await expect(fileContent).toMatchFileSnapshot( 72 + path.join(snapshotsDir, filePath.slice(outputDir.length + 1)), 73 + ); 74 + }), 75 + ); 76 + }); 77 + }); 78 + }
+160
packages/openapi-ts-tests/zod/v4/test/3.1.x.test.ts
··· 1 + import fs from 'node:fs'; 2 + import path from 'node:path'; 3 + 4 + import { createClient } from '@hey-api/openapi-ts'; 5 + import { describe, expect, it } from 'vitest'; 6 + 7 + import { getFilePaths } from '../../../utils'; 8 + import { 9 + createZodConfig, 10 + getSnapshotsPath, 11 + getTempSnapshotsPath, 12 + zodVersions, 13 + } from './utils'; 14 + 15 + const version = '3.1.x'; 16 + 17 + for (const zodVersion of zodVersions) { 18 + const outputDir = path.join( 19 + getTempSnapshotsPath(), 20 + version, 21 + zodVersion.folder, 22 + ); 23 + const snapshotsDir = path.join( 24 + getSnapshotsPath(), 25 + version, 26 + zodVersion.folder, 27 + ); 28 + 29 + describe(`OpenAPI ${version}`, () => { 30 + const createConfig = createZodConfig({ 31 + openApiVersion: version, 32 + outputDir, 33 + zodVersion, 34 + }); 35 + 36 + const scenarios = [ 37 + { 38 + config: createConfig({ 39 + input: 'array-items-one-of-length-1.yaml', 40 + output: 'array-items-one-of-length-1', 41 + }), 42 + description: 43 + 'generates correct array when items are oneOf array with single item', 44 + }, 45 + { 46 + config: createConfig({ 47 + input: 'enum-null.json', 48 + output: 'enum-null', 49 + }), 50 + description: 'handles null enums', 51 + }, 52 + { 53 + config: createConfig({ 54 + input: 'schema-const.yaml', 55 + output: 'schema-const', 56 + }), 57 + description: 'handles various constants', 58 + }, 59 + { 60 + config: createConfig({ 61 + input: 'validators.yaml', 62 + output: 'validators', 63 + }), 64 + description: 'generates validator schemas', 65 + }, 66 + { 67 + config: createConfig({ 68 + input: 'validators.yaml', 69 + output: 'validators-dates', 70 + plugins: [ 71 + { 72 + compatibilityVersion: zodVersion.compatibilityVersion, 73 + dates: { 74 + offset: true, 75 + }, 76 + name: 'zod', 77 + }, 78 + ], 79 + }), 80 + description: 'generates validator schemas with any offset', 81 + }, 82 + { 83 + config: createConfig({ 84 + input: 'validators.yaml', 85 + output: 'validators-metadata', 86 + plugins: [ 87 + { 88 + compatibilityVersion: zodVersion.compatibilityVersion, 89 + metadata: true, 90 + name: 'zod', 91 + }, 92 + ], 93 + }), 94 + description: 'generates validator schemas with metadata', 95 + }, 96 + { 97 + config: createConfig({ 98 + input: 'validators.yaml', 99 + output: 'validators-types', 100 + plugins: [ 101 + { 102 + compatibilityVersion: zodVersion.compatibilityVersion, 103 + name: 'zod', 104 + types: { 105 + infer: true, 106 + }, 107 + }, 108 + ], 109 + }), 110 + description: 'generates validator schemas with types', 111 + }, 112 + { 113 + config: createConfig({ 114 + input: 'validators-bigint-min-max.json', 115 + output: 'validators-bigint-min-max', 116 + }), 117 + description: 'validator schemas with BigInt and min/max constraints', 118 + }, 119 + { 120 + config: createConfig({ 121 + input: 'validators-circular-ref.json', 122 + output: 'validators-circular-ref', 123 + }), 124 + description: 'validator schemas with circular reference', 125 + }, 126 + { 127 + config: createConfig({ 128 + input: 'validators-circular-ref-2.yaml', 129 + output: 'validators-circular-ref-2', 130 + }), 131 + description: 'validator schemas with circular reference 2', 132 + }, 133 + { 134 + config: createConfig({ 135 + input: 'validators-union-merge.json', 136 + output: 'validators-union-merge', 137 + }), 138 + description: 139 + "validator schemas with merged unions (can't use .merge())", 140 + }, 141 + ]; 142 + 143 + it.each(scenarios)('$description', async ({ config }) => { 144 + await createClient(config); 145 + 146 + const outputPath = 147 + typeof config.output === 'string' ? config.output : config.output.path; 148 + const filePaths = getFilePaths(outputPath); 149 + 150 + await Promise.all( 151 + filePaths.map(async (filePath) => { 152 + const fileContent = fs.readFileSync(filePath, 'utf-8'); 153 + await expect(fileContent).toMatchFileSnapshot( 154 + path.join(snapshotsDir, filePath.slice(outputDir.length + 1)), 155 + ); 156 + }), 157 + ); 158 + }); 159 + }); 160 + }
+74
packages/openapi-ts-tests/zod/v4/test/openapi.test.ts
··· 1 + import fs from 'node:fs'; 2 + import path from 'node:path'; 3 + 4 + import { createClient } from '@hey-api/openapi-ts'; 5 + import { describe, expect, it } from 'vitest'; 6 + 7 + import { getFilePaths } from '../../../utils'; 8 + import { 9 + createZodConfig, 10 + getSnapshotsPath, 11 + getTempSnapshotsPath, 12 + zodVersions, 13 + } from './utils'; 14 + 15 + const versions = ['2.0.x', '3.0.x', '3.1.x']; 16 + 17 + for (const version of versions) { 18 + for (const zodVersion of zodVersions) { 19 + const outputDir = path.join( 20 + getTempSnapshotsPath(), 21 + version, 22 + zodVersion.folder, 23 + ); 24 + const snapshotsDir = path.join( 25 + getSnapshotsPath(), 26 + version, 27 + zodVersion.folder, 28 + ); 29 + 30 + describe(`OpenAPI ${version}`, () => { 31 + const createConfig = createZodConfig({ 32 + openApiVersion: version, 33 + outputDir, 34 + zodVersion, 35 + }); 36 + 37 + const scenarios = [ 38 + { 39 + config: createConfig({ 40 + input: 'full.yaml', 41 + output: 'default', 42 + }), 43 + description: 'generate Zod schemas with Zod plugin', 44 + }, 45 + { 46 + config: createConfig({ 47 + input: 'type-format.yaml', 48 + output: 'type-format-zod', 49 + }), 50 + description: 'handles various schema types and formats', 51 + }, 52 + ]; 53 + 54 + it.each(scenarios)('$description', async ({ config }) => { 55 + await createClient(config); 56 + 57 + const outputPath = 58 + typeof config.output === 'string' 59 + ? config.output 60 + : config.output.path; 61 + const filePaths = getFilePaths(outputPath); 62 + 63 + await Promise.all( 64 + filePaths.map(async (filePath) => { 65 + const fileContent = fs.readFileSync(filePath, 'utf-8'); 66 + await expect(fileContent).toMatchFileSnapshot( 67 + path.join(snapshotsDir, filePath.slice(outputDir.length + 1)), 68 + ); 69 + }), 70 + ); 71 + }); 72 + }); 73 + } 74 + }
+73
packages/openapi-ts-tests/zod/v4/test/utils.ts
··· 1 + import path from 'node:path'; 2 + import { fileURLToPath } from 'node:url'; 3 + 4 + import { type UserConfig } from '@hey-api/openapi-ts'; 5 + 6 + import { getSpecsPath } from '../../../utils'; 7 + 8 + const __filename = fileURLToPath(import.meta.url); 9 + const __dirname = path.dirname(__filename); 10 + 11 + export const createZodConfig = 12 + ({ 13 + openApiVersion, 14 + outputDir, 15 + zodVersion, 16 + }: { 17 + openApiVersion: string; 18 + outputDir: string; 19 + zodVersion: (typeof zodVersions)[number]; 20 + }) => 21 + (userConfig: UserConfig): UserConfig => { 22 + const inputPath = path.join( 23 + getSpecsPath(), 24 + openApiVersion, 25 + typeof userConfig.input === 'string' 26 + ? userConfig.input 27 + : (userConfig.input.path as string), 28 + ); 29 + return { 30 + plugins: [ 31 + { 32 + compatibilityVersion: zodVersion.compatibilityVersion, 33 + name: 'zod', 34 + }, 35 + ], 36 + ...userConfig, 37 + input: 38 + typeof userConfig.input === 'string' 39 + ? inputPath 40 + : { 41 + ...userConfig.input, 42 + path: inputPath, 43 + }, 44 + logs: { 45 + level: 'silent', 46 + }, 47 + output: path.join( 48 + outputDir, 49 + typeof userConfig.output === 'string' ? userConfig.output : '', 50 + ), 51 + }; 52 + }; 53 + 54 + export const getSnapshotsPath = (): string => 55 + path.join(__dirname, '..', '__snapshots__'); 56 + 57 + export const getTempSnapshotsPath = (): string => 58 + path.join(__dirname, '..', '.gen', 'snapshots'); 59 + 60 + export const zodVersions = [ 61 + { 62 + compatibilityVersion: 3, 63 + folder: 'v3', 64 + }, 65 + { 66 + compatibilityVersion: 4, 67 + folder: 'v4', 68 + }, 69 + { 70 + compatibilityVersion: 'mini', 71 + folder: 'mini', 72 + }, 73 + ] as const;
+9
packages/openapi-ts-tests/zod/v4/tsconfig.json
··· 1 + { 2 + "extends": "../../tsconfig.base.json", 3 + "compilerOptions": { 4 + "declaration": false, 5 + "esModuleInterop": true, 6 + "resolveJsonModule": true, 7 + "skipLibCheck": true 8 + } 9 + }
+10
packages/openapi-ts-tests/zod/v4/turbo.json
··· 1 + { 2 + "$schema": "../../../node_modules/turbo/schema.json", 3 + "extends": ["//"], 4 + "tasks": { 5 + "build": { 6 + "dependsOn": [], 7 + "outputs": ["dist/**"] 8 + } 9 + } 10 + }
+7
packages/openapi-ts-tests/zod/v4/vitest.config.ts
··· 1 + import { fileURLToPath } from 'node:url'; 2 + 3 + import { createVitestConfig } from '@config/vite-base'; 4 + 5 + export default createVitestConfig( 6 + fileURLToPath(new URL('./', import.meta.url)), 7 + );
+1
packages/openapi-ts/src/compiler/index.ts
··· 31 31 expressionToStatement: convert.expressionToStatement, 32 32 forOfStatement: types.createForOfStatement, 33 33 functionTypeNode: types.createFunctionTypeNode, 34 + getAccessorDeclaration: types.createGetAccessorDeclaration, 34 35 identifier: utils.createIdentifier, 35 36 ifStatement: transform.createIfStatement, 36 37 indexedAccessTypeNode: types.createIndexedAccessTypeNode,
+20 -12
packages/openapi-ts/src/compiler/types.ts
··· 868 868 return node; 869 869 }; 870 870 871 + export const createGetAccessorDeclaration = ({ 872 + name, 873 + returnType, 874 + statements, 875 + }: { 876 + name: string | ts.PropertyName; 877 + returnType?: string | ts.Identifier; 878 + statements: ReadonlyArray<ts.Statement>; 879 + }) => 880 + ts.factory.createGetAccessorDeclaration( 881 + undefined, // modifiers 882 + name, 883 + [], // parameters 884 + returnType ? createTypeReferenceNode({ typeName: returnType }) : undefined, 885 + createBlock({ statements }), 886 + ); 887 + 871 888 export const createStringLiteral = ({ 872 889 isSingleQuote, 873 890 text, ··· 956 973 }: { 957 974 typeArguments?: ts.TypeNode[]; 958 975 typeName: string | ts.EntityName; 959 - }) => { 960 - const node = ts.factory.createTypeReferenceNode(typeName, typeArguments); 961 - return node; 962 - }; 976 + }) => ts.factory.createTypeReferenceNode(typeName, typeArguments); 963 977 964 - export const createTypeParenthesizedNode = ({ 965 - type, 966 - }: { 967 - type: ts.TypeNode; 968 - }) => { 969 - const node = ts.factory.createParenthesizedType(type); 970 - return node; 971 - }; 978 + export const createTypeParenthesizedNode = ({ type }: { type: ts.TypeNode }) => 979 + ts.factory.createParenthesizedType(type); 972 980 973 981 export const createParameterDeclaration = ({ 974 982 initializer,
+2
packages/openapi-ts/src/plugins/zod/constants.ts
··· 1 1 import { compiler } from '../../compiler'; 2 2 3 3 export const identifiers = { 4 + ZodMiniOptional: compiler.identifier({ text: 'ZodMiniOptional' }), 5 + ZodOptional: compiler.identifier({ text: 'ZodOptional' }), 4 6 _default: compiler.identifier({ text: '_default' }), 5 7 and: compiler.identifier({ text: 'and' }), 6 8 array: compiler.identifier({ text: 'array' }),
+258 -198
packages/openapi-ts/src/plugins/zod/mini/plugin.ts
··· 21 21 plugin: ZodPlugin['Instance']; 22 22 schema: SchemaWithType<'array'>; 23 23 state: State; 24 - }): ts.CallExpression => { 24 + }): Omit<ZodSchema, 'typeName'> => { 25 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 26 + 25 27 const functionName = compiler.propertyAccessExpression({ 26 28 expression: identifiers.z, 27 29 name: identifiers.array, 28 30 }); 29 31 30 - let arrayExpression: ts.CallExpression | undefined; 31 - 32 32 if (!schema.items) { 33 - arrayExpression = compiler.callExpression({ 33 + result.expression = compiler.callExpression({ 34 34 functionName, 35 35 parameters: [ 36 36 unknownTypeToZodSchema({ 37 37 schema: { 38 38 type: 'unknown', 39 39 }, 40 - }), 40 + }).expression, 41 41 ], 42 42 }); 43 43 } else { 44 44 schema = deduplicateSchema({ schema }); 45 45 46 46 // at least one item is guaranteed 47 - const itemExpressions = schema.items!.map( 48 - (item) => 49 - schemaToZodSchema({ 50 - plugin, 51 - schema: item, 52 - state, 53 - }).expression, 54 - ); 47 + const itemExpressions = schema.items!.map((item) => { 48 + const zodSchema = schemaToZodSchema({ 49 + plugin, 50 + schema: item, 51 + state, 52 + }); 53 + if (zodSchema.hasCircularReference) { 54 + result.hasCircularReference = true; 55 + } 56 + return zodSchema.expression; 57 + }); 55 58 56 59 if (itemExpressions.length === 1) { 57 - arrayExpression = compiler.callExpression({ 60 + result.expression = compiler.callExpression({ 58 61 functionName, 59 62 parameters: itemExpressions, 60 63 }); ··· 66 69 // ); 67 70 } 68 71 69 - arrayExpression = compiler.callExpression({ 72 + result.expression = compiler.callExpression({ 70 73 functionName: compiler.propertyAccessExpression({ 71 74 expression: identifiers.z, 72 75 name: identifiers.array, ··· 88 91 } 89 92 } 90 93 94 + const checks: Array<ts.Expression> = []; 95 + 91 96 if (schema.minItems === schema.maxItems && schema.minItems !== undefined) { 92 - arrayExpression = compiler.callExpression({ 93 - functionName: compiler.propertyAccessExpression({ 94 - expression: arrayExpression, 95 - name: identifiers.length, 97 + checks.push( 98 + compiler.callExpression({ 99 + functionName: compiler.propertyAccessExpression({ 100 + expression: identifiers.z, 101 + name: identifiers.length, 102 + }), 103 + parameters: [compiler.valueToExpression({ value: schema.minItems })], 96 104 }), 97 - parameters: [compiler.valueToExpression({ value: schema.minItems })], 98 - }); 105 + ); 99 106 } else { 100 107 if (schema.minItems !== undefined) { 101 - arrayExpression = compiler.callExpression({ 102 - functionName: compiler.propertyAccessExpression({ 103 - expression: arrayExpression, 104 - name: identifiers.min, 108 + checks.push( 109 + compiler.callExpression({ 110 + functionName: compiler.propertyAccessExpression({ 111 + expression: identifiers.z, 112 + name: identifiers.minLength, 113 + }), 114 + parameters: [compiler.valueToExpression({ value: schema.minItems })], 105 115 }), 106 - parameters: [compiler.valueToExpression({ value: schema.minItems })], 107 - }); 116 + ); 108 117 } 109 118 110 119 if (schema.maxItems !== undefined) { 111 - arrayExpression = compiler.callExpression({ 112 - functionName: compiler.propertyAccessExpression({ 113 - expression: arrayExpression, 114 - name: identifiers.max, 120 + checks.push( 121 + compiler.callExpression({ 122 + functionName: compiler.propertyAccessExpression({ 123 + expression: identifiers.z, 124 + name: identifiers.maxLength, 125 + }), 126 + parameters: [compiler.valueToExpression({ value: schema.maxItems })], 115 127 }), 116 - parameters: [compiler.valueToExpression({ value: schema.maxItems })], 117 - }); 128 + ); 118 129 } 119 130 } 120 131 121 - return arrayExpression; 132 + if (checks.length) { 133 + result.expression = compiler.callExpression({ 134 + functionName: compiler.propertyAccessExpression({ 135 + expression: result.expression, 136 + name: identifiers.check, 137 + }), 138 + parameters: checks, 139 + }); 140 + } 141 + 142 + return result as Omit<ZodSchema, 'typeName'>; 122 143 }; 123 144 124 145 const booleanTypeToZodSchema = ({ 125 146 schema, 126 147 }: { 127 148 schema: SchemaWithType<'boolean'>; 128 - }) => { 149 + }): Omit<ZodSchema, 'typeName'> => { 150 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 151 + 129 152 if (typeof schema.const === 'boolean') { 130 - const expression = compiler.callExpression({ 153 + result.expression = compiler.callExpression({ 131 154 functionName: compiler.propertyAccessExpression({ 132 155 expression: identifiers.z, 133 156 name: identifiers.literal, 134 157 }), 135 158 parameters: [compiler.ots.boolean(schema.const)], 136 159 }); 137 - return expression; 160 + return result as Omit<ZodSchema, 'typeName'>; 138 161 } 139 162 140 - const expression = compiler.callExpression({ 163 + result.expression = compiler.callExpression({ 141 164 functionName: compiler.propertyAccessExpression({ 142 165 expression: identifiers.z, 143 166 name: identifiers.boolean, 144 167 }), 145 168 }); 146 - return expression; 169 + return result as Omit<ZodSchema, 'typeName'>; 147 170 }; 148 171 149 172 const enumTypeToZodSchema = ({ 150 173 schema, 151 174 }: { 152 175 schema: SchemaWithType<'enum'>; 153 - }): ts.CallExpression => { 176 + }): Omit<ZodSchema, 'typeName'> => { 177 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 178 + 154 179 const enumMembers: Array<ts.LiteralExpression> = []; 155 180 156 181 let isNullable = false; ··· 176 201 }); 177 202 } 178 203 179 - let enumExpression = compiler.callExpression({ 204 + result.expression = compiler.callExpression({ 180 205 functionName: compiler.propertyAccessExpression({ 181 206 expression: identifiers.z, 182 207 name: identifiers.enum, ··· 190 215 }); 191 216 192 217 if (isNullable) { 193 - enumExpression = compiler.callExpression({ 218 + result.expression = compiler.callExpression({ 194 219 functionName: compiler.propertyAccessExpression({ 195 - expression: enumExpression, 220 + expression: identifiers.z, 196 221 name: identifiers.nullable, 197 222 }), 223 + parameters: [result.expression], 198 224 }); 199 225 } 200 226 201 - return enumExpression; 227 + return result as Omit<ZodSchema, 'typeName'>; 202 228 }; 203 229 204 230 // eslint-disable-next-line @typescript-eslint/no-unused-vars 205 - const neverTypeToZodSchema = (_props: { schema: SchemaWithType<'never'> }) => { 206 - const expression = compiler.callExpression({ 231 + const neverTypeToZodSchema = (_props: { 232 + schema: SchemaWithType<'never'>; 233 + }): Omit<ZodSchema, 'typeName'> => { 234 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 235 + result.expression = compiler.callExpression({ 207 236 functionName: compiler.propertyAccessExpression({ 208 237 expression: identifiers.z, 209 238 name: identifiers.never, 210 239 }), 211 240 }); 212 - return expression; 241 + return result as Omit<ZodSchema, 'typeName'>; 213 242 }; 214 243 215 244 // eslint-disable-next-line @typescript-eslint/no-unused-vars 216 - const nullTypeToZodSchema = (_props: { schema: SchemaWithType<'null'> }) => { 217 - const expression = compiler.callExpression({ 245 + const nullTypeToZodSchema = (_props: { 246 + schema: SchemaWithType<'null'>; 247 + }): Omit<ZodSchema, 'typeName'> => { 248 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 249 + result.expression = compiler.callExpression({ 218 250 functionName: compiler.propertyAccessExpression({ 219 251 expression: identifiers.z, 220 252 name: identifiers.null, 221 253 }), 222 254 }); 223 - return expression; 255 + return result as Omit<ZodSchema, 'typeName'>; 224 256 }; 225 257 226 258 const numberParameter = ({ ··· 229 261 }: { 230 262 isBigInt: boolean; 231 263 value: unknown; 232 - }) => { 264 + }): ts.Expression | undefined => { 233 265 const expression = compiler.valueToExpression({ value }); 234 266 235 267 if ( ··· 252 284 schema, 253 285 }: { 254 286 schema: SchemaWithType<'integer' | 'number'>; 255 - }) => { 287 + }): Omit<ZodSchema, 'typeName'> => { 288 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 289 + 256 290 const isBigInt = schema.type === 'integer' && schema.format === 'int64'; 257 291 258 292 if (typeof schema.const === 'number') { 259 293 // TODO: parser - handle bigint constants 260 - const expression = compiler.callExpression({ 294 + result.expression = compiler.callExpression({ 261 295 functionName: compiler.propertyAccessExpression({ 262 296 expression: identifiers.z, 263 297 name: identifiers.literal, 264 298 }), 265 299 parameters: [compiler.ots.number(schema.const)], 266 300 }); 267 - return expression; 301 + return result as Omit<ZodSchema, 'typeName'>; 268 302 } 269 303 270 - let numberExpression = compiler.callExpression({ 304 + result.expression = compiler.callExpression({ 271 305 functionName: isBigInt 272 306 ? compiler.propertyAccessExpression({ 273 307 expression: compiler.propertyAccessExpression({ ··· 283 317 }); 284 318 285 319 if (!isBigInt && schema.type === 'integer') { 286 - numberExpression = compiler.callExpression({ 320 + result.expression = compiler.callExpression({ 287 321 functionName: compiler.propertyAccessExpression({ 288 322 expression: identifiers.z, 289 323 name: identifiers.int, ··· 342 376 } 343 377 344 378 if (checks.length) { 345 - numberExpression = compiler.callExpression({ 379 + result.expression = compiler.callExpression({ 346 380 functionName: compiler.propertyAccessExpression({ 347 - expression: numberExpression, 381 + expression: result.expression, 348 382 name: identifiers.check, 349 383 }), 350 384 parameters: checks, 351 385 }); 352 386 } 353 387 354 - return numberExpression; 388 + return result as Omit<ZodSchema, 'typeName'>; 355 389 }; 356 390 357 391 const objectTypeToZodSchema = ({ ··· 362 396 plugin: ZodPlugin['Instance']; 363 397 schema: SchemaWithType<'object'>; 364 398 state: State; 365 - }): { 366 - expression: ts.CallExpression; 367 - } => { 399 + }): Omit<ZodSchema, 'typeName'> => { 400 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 401 + 368 402 // TODO: parser - handle constants 369 - const properties: Array<ts.PropertyAssignment> = []; 403 + const properties: Array<ts.PropertyAssignment | ts.GetAccessorDeclaration> = 404 + []; 370 405 371 406 const required = schema.required ?? []; 372 407 ··· 374 409 const property = schema.properties[name]!; 375 410 const isRequired = required.includes(name); 376 411 377 - const propertyExpression = schemaToZodSchema({ 412 + const propertySchema = schemaToZodSchema({ 378 413 optional: !isRequired, 379 414 plugin, 380 415 schema: property, 381 416 state, 382 - }).expression; 417 + }); 418 + if (propertySchema.hasCircularReference) { 419 + result.hasCircularReference = true; 420 + } 383 421 384 422 numberRegExp.lastIndex = 0; 385 423 let propertyName; ··· 400 438 ) { 401 439 propertyName = `'${name}'`; 402 440 } 403 - properties.push( 404 - compiler.propertyAssignment({ 405 - initializer: propertyExpression, 406 - name: propertyName, 407 - }), 408 - ); 441 + 442 + if (propertySchema.hasCircularReference) { 443 + properties.push( 444 + compiler.getAccessorDeclaration({ 445 + name: propertyName, 446 + // @ts-expect-error 447 + returnType: propertySchema.typeName 448 + ? compiler.propertyAccessExpression({ 449 + expression: identifiers.z, 450 + name: propertySchema.typeName, 451 + }) 452 + : undefined, 453 + statements: [ 454 + compiler.returnStatement({ 455 + expression: propertySchema.expression, 456 + }), 457 + ], 458 + }), 459 + ); 460 + } else { 461 + properties.push( 462 + compiler.propertyAssignment({ 463 + initializer: propertySchema.expression, 464 + name: propertyName, 465 + }), 466 + ); 467 + } 409 468 } 410 469 411 470 if ( ··· 417 476 plugin, 418 477 schema: schema.additionalProperties, 419 478 state, 420 - }).expression; 421 - const expression = compiler.callExpression({ 479 + }); 480 + result.expression = compiler.callExpression({ 422 481 functionName: compiler.propertyAccessExpression({ 423 482 expression: identifiers.z, 424 483 name: identifiers.record, ··· 431 490 }), 432 491 parameters: [], 433 492 }), 434 - zodSchema, 493 + zodSchema.expression, 435 494 ], 436 495 }); 437 - return { 438 - expression, 439 - }; 496 + if (zodSchema.hasCircularReference) { 497 + result.hasCircularReference = true; 498 + } 499 + return result as Omit<ZodSchema, 'typeName'>; 440 500 } 441 501 442 - const expression = compiler.callExpression({ 502 + result.expression = compiler.callExpression({ 443 503 functionName: compiler.propertyAccessExpression({ 444 504 expression: identifiers.z, 445 505 name: identifiers.object, 446 506 }), 447 507 parameters: [ts.factory.createObjectLiteralExpression(properties, true)], 448 508 }); 449 - return { 450 - expression, 451 - }; 509 + 510 + return result as Omit<ZodSchema, 'typeName'>; 452 511 }; 453 512 454 513 const stringTypeToZodSchema = ({ ··· 457 516 }: { 458 517 plugin: ZodPlugin['Instance']; 459 518 schema: SchemaWithType<'string'>; 460 - }) => { 519 + }): Omit<ZodSchema, 'typeName'> => { 520 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 521 + 461 522 if (typeof schema.const === 'string') { 462 - const expression = compiler.callExpression({ 523 + result.expression = compiler.callExpression({ 463 524 functionName: compiler.propertyAccessExpression({ 464 525 expression: identifiers.z, 465 526 name: identifiers.literal, 466 527 }), 467 528 parameters: [compiler.ots.string(schema.const)], 468 529 }); 469 - return expression; 530 + return result as Omit<ZodSchema, 'typeName'>; 470 531 } 471 532 472 - let stringExpression = compiler.callExpression({ 533 + result.expression = compiler.callExpression({ 473 534 functionName: compiler.propertyAccessExpression({ 474 535 expression: identifiers.z, 475 536 name: identifiers.string, ··· 479 540 if (schema.format) { 480 541 switch (schema.format) { 481 542 case 'date': 482 - stringExpression = compiler.callExpression({ 543 + result.expression = compiler.callExpression({ 483 544 functionName: compiler.propertyAccessExpression({ 484 545 expression: compiler.propertyAccessExpression({ 485 546 expression: identifiers.z, ··· 490 551 }); 491 552 break; 492 553 case 'date-time': 493 - stringExpression = compiler.callExpression({ 554 + result.expression = compiler.callExpression({ 494 555 functionName: compiler.propertyAccessExpression({ 495 556 expression: compiler.propertyAccessExpression({ 496 557 expression: identifiers.z, ··· 513 574 }); 514 575 break; 515 576 case 'email': 516 - stringExpression = compiler.callExpression({ 577 + result.expression = compiler.callExpression({ 517 578 functionName: compiler.propertyAccessExpression({ 518 579 expression: identifiers.z, 519 580 name: identifiers.email, ··· 521 582 }); 522 583 break; 523 584 case 'ipv4': 524 - stringExpression = compiler.callExpression({ 585 + result.expression = compiler.callExpression({ 525 586 functionName: compiler.propertyAccessExpression({ 526 587 expression: identifiers.z, 527 588 name: identifiers.ipv4, ··· 529 590 }); 530 591 break; 531 592 case 'ipv6': 532 - stringExpression = compiler.callExpression({ 593 + result.expression = compiler.callExpression({ 533 594 functionName: compiler.propertyAccessExpression({ 534 595 expression: identifiers.z, 535 596 name: identifiers.ipv6, ··· 537 598 }); 538 599 break; 539 600 case 'time': 540 - stringExpression = compiler.callExpression({ 601 + result.expression = compiler.callExpression({ 541 602 functionName: compiler.propertyAccessExpression({ 542 603 expression: compiler.propertyAccessExpression({ 543 604 expression: identifiers.z, ··· 548 609 }); 549 610 break; 550 611 case 'uri': 551 - stringExpression = compiler.callExpression({ 612 + result.expression = compiler.callExpression({ 552 613 functionName: compiler.propertyAccessExpression({ 553 614 expression: identifiers.z, 554 615 name: identifiers.url, ··· 556 617 }); 557 618 break; 558 619 case 'uuid': 559 - stringExpression = compiler.callExpression({ 620 + result.expression = compiler.callExpression({ 560 621 functionName: compiler.propertyAccessExpression({ 561 622 expression: identifiers.z, 562 623 name: identifiers.uuid, ··· 619 680 } 620 681 621 682 if (checks.length) { 622 - stringExpression = compiler.callExpression({ 683 + result.expression = compiler.callExpression({ 623 684 functionName: compiler.propertyAccessExpression({ 624 - expression: stringExpression, 685 + expression: result.expression, 625 686 name: identifiers.check, 626 687 }), 627 688 parameters: checks, 628 689 }); 629 690 } 630 691 631 - return stringExpression; 692 + return result as Omit<ZodSchema, 'typeName'>; 632 693 }; 633 694 634 695 const tupleTypeToZodSchema = ({ ··· 639 700 plugin: ZodPlugin['Instance']; 640 701 schema: SchemaWithType<'tuple'>; 641 702 state: State; 642 - }) => { 703 + }): Omit<ZodSchema, 'typeName'> => { 704 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 705 + 643 706 if (schema.const && Array.isArray(schema.const)) { 644 707 const tupleElements = schema.const.map((value) => 645 708 compiler.callExpression({ ··· 650 713 parameters: [compiler.valueToExpression({ value })], 651 714 }), 652 715 ); 653 - const expression = compiler.callExpression({ 716 + result.expression = compiler.callExpression({ 654 717 functionName: compiler.propertyAccessExpression({ 655 718 expression: identifiers.z, 656 719 name: identifiers.tuple, ··· 661 724 }), 662 725 ], 663 726 }); 664 - return expression; 727 + return result as Omit<ZodSchema, 'typeName'>; 665 728 } 666 729 667 730 const tupleElements: Array<ts.Expression> = []; 668 731 669 732 for (const item of schema.items ?? []) { 670 - tupleElements.push( 671 - schemaToZodSchema({ 672 - plugin, 673 - schema: item, 674 - state, 675 - }).expression, 676 - ); 733 + const itemSchema = schemaToZodSchema({ 734 + plugin, 735 + schema: item, 736 + state, 737 + }); 738 + tupleElements.push(itemSchema.expression); 739 + 740 + if (itemSchema.hasCircularReference) { 741 + result.hasCircularReference = true; 742 + } 677 743 } 678 744 679 - const expression = compiler.callExpression({ 745 + result.expression = compiler.callExpression({ 680 746 functionName: compiler.propertyAccessExpression({ 681 747 expression: identifiers.z, 682 748 name: identifiers.tuple, ··· 687 753 }), 688 754 ], 689 755 }); 690 - return expression; 756 + 757 + return result as Omit<ZodSchema, 'typeName'>; 691 758 }; 692 759 693 760 // eslint-disable-next-line @typescript-eslint/no-unused-vars 694 761 const undefinedTypeToZodSchema = (_props: { 695 762 schema: SchemaWithType<'undefined'>; 696 - }) => { 697 - const expression = compiler.callExpression({ 763 + }): Omit<ZodSchema, 'typeName'> => { 764 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 765 + result.expression = compiler.callExpression({ 698 766 functionName: compiler.propertyAccessExpression({ 699 767 expression: identifiers.z, 700 768 name: identifiers.undefined, 701 769 }), 702 770 }); 703 - return expression; 771 + return result as Omit<ZodSchema, 'typeName'>; 704 772 }; 705 773 706 774 // eslint-disable-next-line @typescript-eslint/no-unused-vars 707 775 const unknownTypeToZodSchema = (_props: { 708 776 schema: SchemaWithType<'unknown'>; 709 - }) => { 710 - const expression = compiler.callExpression({ 777 + }): Omit<ZodSchema, 'typeName'> => { 778 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 779 + result.expression = compiler.callExpression({ 711 780 functionName: compiler.propertyAccessExpression({ 712 781 expression: identifiers.z, 713 782 name: identifiers.unknown, 714 783 }), 715 784 }); 716 - return expression; 785 + return result as Omit<ZodSchema, 'typeName'>; 717 786 }; 718 787 719 788 // eslint-disable-next-line @typescript-eslint/no-unused-vars 720 - const voidTypeToZodSchema = (_props: { schema: SchemaWithType<'void'> }) => { 721 - const expression = compiler.callExpression({ 789 + const voidTypeToZodSchema = (_props: { 790 + schema: SchemaWithType<'void'>; 791 + }): Omit<ZodSchema, 'typeName'> => { 792 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 793 + result.expression = compiler.callExpression({ 722 794 functionName: compiler.propertyAccessExpression({ 723 795 expression: identifiers.z, 724 796 name: identifiers.void, 725 797 }), 726 798 }); 727 - return expression; 799 + return result as Omit<ZodSchema, 'typeName'>; 728 800 }; 729 801 730 802 const schemaTypeToZodSchema = ({ ··· 735 807 plugin: ZodPlugin['Instance']; 736 808 schema: IR.SchemaObject; 737 809 state: State; 738 - }): { 739 - expression: ts.Expression; 740 - } => { 810 + }): Omit<ZodSchema, 'typeName'> => { 741 811 switch (schema.type as Required<IR.SchemaObject>['type']) { 742 812 case 'array': 743 - return { 744 - expression: arrayTypeToZodSchema({ 745 - plugin, 746 - schema: schema as SchemaWithType<'array'>, 747 - state, 748 - }), 749 - }; 813 + return arrayTypeToZodSchema({ 814 + plugin, 815 + schema: schema as SchemaWithType<'array'>, 816 + state, 817 + }); 750 818 case 'boolean': 751 - return { 752 - expression: booleanTypeToZodSchema({ 753 - schema: schema as SchemaWithType<'boolean'>, 754 - }), 755 - }; 819 + return booleanTypeToZodSchema({ 820 + schema: schema as SchemaWithType<'boolean'>, 821 + }); 756 822 case 'enum': 757 - return { 758 - expression: enumTypeToZodSchema({ 759 - schema: schema as SchemaWithType<'enum'>, 760 - }), 761 - }; 823 + return enumTypeToZodSchema({ 824 + schema: schema as SchemaWithType<'enum'>, 825 + }); 762 826 case 'integer': 763 827 case 'number': 764 - return { 765 - expression: numberTypeToZodSchema({ 766 - schema: schema as SchemaWithType<'integer' | 'number'>, 767 - }), 768 - }; 828 + return numberTypeToZodSchema({ 829 + schema: schema as SchemaWithType<'integer' | 'number'>, 830 + }); 769 831 case 'never': 770 - return { 771 - expression: neverTypeToZodSchema({ 772 - schema: schema as SchemaWithType<'never'>, 773 - }), 774 - }; 832 + return neverTypeToZodSchema({ 833 + schema: schema as SchemaWithType<'never'>, 834 + }); 775 835 case 'null': 776 - return { 777 - expression: nullTypeToZodSchema({ 778 - schema: schema as SchemaWithType<'null'>, 779 - }), 780 - }; 836 + return nullTypeToZodSchema({ 837 + schema: schema as SchemaWithType<'null'>, 838 + }); 781 839 case 'object': 782 840 return objectTypeToZodSchema({ 783 841 plugin, ··· 785 843 state, 786 844 }); 787 845 case 'string': 788 - return { 789 - expression: stringTypeToZodSchema({ 790 - plugin, 791 - schema: schema as SchemaWithType<'string'>, 792 - }), 793 - }; 846 + return stringTypeToZodSchema({ 847 + plugin, 848 + schema: schema as SchemaWithType<'string'>, 849 + }); 794 850 case 'tuple': 795 - return { 796 - expression: tupleTypeToZodSchema({ 797 - plugin, 798 - schema: schema as SchemaWithType<'tuple'>, 799 - state, 800 - }), 801 - }; 851 + return tupleTypeToZodSchema({ 852 + plugin, 853 + schema: schema as SchemaWithType<'tuple'>, 854 + state, 855 + }); 802 856 case 'undefined': 803 - return { 804 - expression: undefinedTypeToZodSchema({ 805 - schema: schema as SchemaWithType<'undefined'>, 806 - }), 807 - }; 857 + return undefinedTypeToZodSchema({ 858 + schema: schema as SchemaWithType<'undefined'>, 859 + }); 808 860 case 'unknown': 809 - return { 810 - expression: unknownTypeToZodSchema({ 811 - schema: schema as SchemaWithType<'unknown'>, 812 - }), 813 - }; 861 + return unknownTypeToZodSchema({ 862 + schema: schema as SchemaWithType<'unknown'>, 863 + }); 814 864 case 'void': 815 - return { 816 - expression: voidTypeToZodSchema({ 817 - schema: schema as SchemaWithType<'void'>, 818 - }), 819 - }; 865 + return voidTypeToZodSchema({ 866 + schema: schema as SchemaWithType<'void'>, 867 + }); 820 868 } 821 869 }; 822 870 ··· 844 892 const isCircularReference = state.circularReferenceTracker.includes( 845 893 schema.$ref, 846 894 ); 895 + const isSelfReference = state.currentReferenceTracker.includes(schema.$ref); 847 896 state.circularReferenceTracker.push(schema.$ref); 897 + state.currentReferenceTracker.push(schema.$ref); 848 898 849 899 const id = plugin.api.getId({ type: 'ref', value: schema.$ref }); 850 900 ··· 852 902 const expression = file.addNodeReference(id, { 853 903 factory: (text) => compiler.identifier({ text }), 854 904 }); 855 - zodSchema.expression = compiler.callExpression({ 856 - functionName: compiler.propertyAccessExpression({ 857 - expression: identifiers.z, 858 - name: identifiers.lazy, 859 - }), 860 - parameters: [ 861 - compiler.arrowFunction({ 862 - statements: [compiler.returnStatement({ expression })], 905 + if (isSelfReference) { 906 + zodSchema.expression = compiler.callExpression({ 907 + functionName: compiler.propertyAccessExpression({ 908 + expression: identifiers.z, 909 + name: identifiers.lazy, 863 910 }), 864 - ], 865 - }); 911 + parameters: [ 912 + compiler.arrowFunction({ 913 + returnType: compiler.keywordTypeNode({ keyword: 'any' }), 914 + statements: [compiler.returnStatement({ expression })], 915 + }), 916 + ], 917 + }); 918 + } else { 919 + zodSchema.expression = expression; 920 + } 921 + zodSchema.hasCircularReference = true; 866 922 } else if (!file.getName(id)) { 867 923 // if $ref hasn't been processed yet, inline it to avoid the 868 924 // "Block-scoped variable used before its declaration." error ··· 884 940 } 885 941 886 942 state.circularReferenceTracker.pop(); 943 + state.currentReferenceTracker.pop(); 887 944 } else if (schema.type) { 888 945 const zSchema = schemaTypeToZodSchema({ plugin, schema, state }); 889 946 zodSchema.expression = zSchema.expression; 947 + zodSchema.hasCircularReference = zSchema.hasCircularReference; 890 948 891 949 if (plugin.config.metadata && schema.description) { 892 950 zodSchema.expression = compiler.callExpression({ ··· 998 1056 }), 999 1057 parameters: [zodSchema.expression], 1000 1058 }); 1059 + zodSchema.typeName = identifiers.ZodMiniOptional; 1001 1060 } 1002 1061 1003 1062 if (schema.default !== undefined) { ··· 1025 1084 id, 1026 1085 plugin, 1027 1086 schema, 1028 - state, 1087 + state: _state, 1029 1088 }: { 1030 1089 id: string; 1031 1090 plugin: ZodPlugin['Instance']; 1032 1091 schema: IR.SchemaObject; 1033 - state?: State; 1092 + state?: Omit<State, 'currentReferenceTracker'>; 1034 1093 }): void => { 1035 - if (!state) { 1036 - state = { 1037 - circularReferenceTracker: [id], 1038 - hasCircularReference: false, 1039 - }; 1040 - } 1094 + const state: State = { 1095 + circularReferenceTracker: [id], 1096 + hasCircularReference: false, 1097 + ..._state, 1098 + currentReferenceTracker: [id], 1099 + }; 1041 1100 1042 1101 const file = plugin.context.file({ id: zodId })!; 1043 1102 const schemaId = plugin.api.getId({ type: 'ref', value: id }); ··· 1093 1152 getZodSchema: (schema) => { 1094 1153 const state: State = { 1095 1154 circularReferenceTracker: [], 1155 + currentReferenceTracker: [], 1096 1156 hasCircularReference: false, 1097 1157 }; 1098 1158 return schemaToZodSchema({ plugin, schema, state });
+8 -1
packages/openapi-ts/src/plugins/zod/shared/types.d.ts
··· 9 9 10 10 export type State = { 11 11 circularReferenceTracker: Array<string>; 12 + /** 13 + * Works the same as `circularReferenceTracker`, but it resets whenever we 14 + * walk inside another schema. This can be used to detect if a schema 15 + * directly references itself. 16 + */ 17 + currentReferenceTracker: Array<string>; 12 18 hasCircularReference: boolean; 13 19 }; 14 20 15 21 export type ZodSchema = { 16 22 expression: ts.Expression; 17 - typeName?: string; 23 + hasCircularReference?: boolean; 24 + typeName?: string | ts.Identifier; 18 25 };
+4
packages/openapi-ts/src/plugins/zod/v3/plugin.ts
··· 782 782 schema.$ref, 783 783 ); 784 784 state.circularReferenceTracker.push(schema.$ref); 785 + state.currentReferenceTracker.push(schema.$ref); 785 786 786 787 const id = plugin.api.getId({ type: 'ref', value: schema.$ref }); 787 788 ··· 822 823 } 823 824 824 825 state.circularReferenceTracker.pop(); 826 + state.currentReferenceTracker.pop(); 825 827 } else if (schema.type) { 826 828 const zSchema = schemaTypeToZodSchema({ plugin, schema, state }); 827 829 zodSchema.expression = zSchema.expression; ··· 968 970 if (!state) { 969 971 state = { 970 972 circularReferenceTracker: [id], 973 + currentReferenceTracker: [id], 971 974 hasCircularReference: false, 972 975 }; 973 976 } ··· 1025 1028 getZodSchema: (schema) => { 1026 1029 const state: State = { 1027 1030 circularReferenceTracker: [], 1031 + currentReferenceTracker: [], 1028 1032 hasCircularReference: false, 1029 1033 }; 1030 1034 return schemaToZodSchema({ plugin, schema, state });
+240 -198
packages/openapi-ts/src/plugins/zod/v4/plugin.ts
··· 21 21 plugin: ZodPlugin['Instance']; 22 22 schema: SchemaWithType<'array'>; 23 23 state: State; 24 - }): ts.CallExpression => { 24 + }): Omit<ZodSchema, 'typeName'> => { 25 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 26 + 25 27 const functionName = compiler.propertyAccessExpression({ 26 28 expression: identifiers.z, 27 29 name: identifiers.array, 28 30 }); 29 31 30 - let arrayExpression: ts.CallExpression | undefined; 31 - 32 32 if (!schema.items) { 33 - arrayExpression = compiler.callExpression({ 33 + result.expression = compiler.callExpression({ 34 34 functionName, 35 35 parameters: [ 36 36 unknownTypeToZodSchema({ 37 37 schema: { 38 38 type: 'unknown', 39 39 }, 40 - }), 40 + }).expression, 41 41 ], 42 42 }); 43 43 } else { 44 44 schema = deduplicateSchema({ schema }); 45 45 46 46 // at least one item is guaranteed 47 - const itemExpressions = schema.items!.map( 48 - (item) => 49 - schemaToZodSchema({ 50 - plugin, 51 - schema: item, 52 - state, 53 - }).expression, 54 - ); 47 + const itemExpressions = schema.items!.map((item) => { 48 + const zodSchema = schemaToZodSchema({ 49 + plugin, 50 + schema: item, 51 + state, 52 + }); 53 + if (zodSchema.hasCircularReference) { 54 + result.hasCircularReference = true; 55 + } 56 + return zodSchema.expression; 57 + }); 55 58 56 59 if (itemExpressions.length === 1) { 57 - arrayExpression = compiler.callExpression({ 60 + result.expression = compiler.callExpression({ 58 61 functionName, 59 62 parameters: itemExpressions, 60 63 }); ··· 66 69 // ); 67 70 } 68 71 69 - arrayExpression = compiler.callExpression({ 72 + result.expression = compiler.callExpression({ 70 73 functionName: compiler.propertyAccessExpression({ 71 74 expression: identifiers.z, 72 75 name: identifiers.array, ··· 89 92 } 90 93 91 94 if (schema.minItems === schema.maxItems && schema.minItems !== undefined) { 92 - arrayExpression = compiler.callExpression({ 95 + result.expression = compiler.callExpression({ 93 96 functionName: compiler.propertyAccessExpression({ 94 - expression: arrayExpression, 97 + expression: result.expression, 95 98 name: identifiers.length, 96 99 }), 97 100 parameters: [compiler.valueToExpression({ value: schema.minItems })], 98 101 }); 99 102 } else { 100 103 if (schema.minItems !== undefined) { 101 - arrayExpression = compiler.callExpression({ 104 + result.expression = compiler.callExpression({ 102 105 functionName: compiler.propertyAccessExpression({ 103 - expression: arrayExpression, 106 + expression: result.expression, 104 107 name: identifiers.min, 105 108 }), 106 109 parameters: [compiler.valueToExpression({ value: schema.minItems })], ··· 108 111 } 109 112 110 113 if (schema.maxItems !== undefined) { 111 - arrayExpression = compiler.callExpression({ 114 + result.expression = compiler.callExpression({ 112 115 functionName: compiler.propertyAccessExpression({ 113 - expression: arrayExpression, 116 + expression: result.expression, 114 117 name: identifiers.max, 115 118 }), 116 119 parameters: [compiler.valueToExpression({ value: schema.maxItems })], ··· 118 121 } 119 122 } 120 123 121 - return arrayExpression; 124 + return result as Omit<ZodSchema, 'typeName'>; 122 125 }; 123 126 124 127 const booleanTypeToZodSchema = ({ 125 128 schema, 126 129 }: { 127 130 schema: SchemaWithType<'boolean'>; 128 - }) => { 131 + }): Omit<ZodSchema, 'typeName'> => { 132 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 133 + 129 134 if (typeof schema.const === 'boolean') { 130 - const expression = compiler.callExpression({ 135 + result.expression = compiler.callExpression({ 131 136 functionName: compiler.propertyAccessExpression({ 132 137 expression: identifiers.z, 133 138 name: identifiers.literal, 134 139 }), 135 140 parameters: [compiler.ots.boolean(schema.const)], 136 141 }); 137 - return expression; 142 + return result as Omit<ZodSchema, 'typeName'>; 138 143 } 139 144 140 - const expression = compiler.callExpression({ 145 + result.expression = compiler.callExpression({ 141 146 functionName: compiler.propertyAccessExpression({ 142 147 expression: identifiers.z, 143 148 name: identifiers.boolean, 144 149 }), 145 150 }); 146 - return expression; 151 + return result as Omit<ZodSchema, 'typeName'>; 147 152 }; 148 153 149 154 const enumTypeToZodSchema = ({ 150 155 schema, 151 156 }: { 152 157 schema: SchemaWithType<'enum'>; 153 - }): ts.CallExpression => { 158 + }): Omit<ZodSchema, 'typeName'> => { 159 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 160 + 154 161 const enumMembers: Array<ts.LiteralExpression> = []; 155 162 156 163 let isNullable = false; ··· 176 183 }); 177 184 } 178 185 179 - let enumExpression = compiler.callExpression({ 186 + result.expression = compiler.callExpression({ 180 187 functionName: compiler.propertyAccessExpression({ 181 188 expression: identifiers.z, 182 189 name: identifiers.enum, ··· 190 197 }); 191 198 192 199 if (isNullable) { 193 - enumExpression = compiler.callExpression({ 200 + result.expression = compiler.callExpression({ 194 201 functionName: compiler.propertyAccessExpression({ 195 - expression: enumExpression, 202 + expression: identifiers.z, 196 203 name: identifiers.nullable, 197 204 }), 205 + parameters: [result.expression], 198 206 }); 199 207 } 200 208 201 - return enumExpression; 209 + return result as Omit<ZodSchema, 'typeName'>; 202 210 }; 203 211 204 212 // eslint-disable-next-line @typescript-eslint/no-unused-vars 205 - const neverTypeToZodSchema = (_props: { schema: SchemaWithType<'never'> }) => { 206 - const expression = compiler.callExpression({ 213 + const neverTypeToZodSchema = (_props: { 214 + schema: SchemaWithType<'never'>; 215 + }): Omit<ZodSchema, 'typeName'> => { 216 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 217 + result.expression = compiler.callExpression({ 207 218 functionName: compiler.propertyAccessExpression({ 208 219 expression: identifiers.z, 209 220 name: identifiers.never, 210 221 }), 211 222 }); 212 - return expression; 223 + return result as Omit<ZodSchema, 'typeName'>; 213 224 }; 214 225 215 226 // eslint-disable-next-line @typescript-eslint/no-unused-vars 216 - const nullTypeToZodSchema = (_props: { schema: SchemaWithType<'null'> }) => { 217 - const expression = compiler.callExpression({ 227 + const nullTypeToZodSchema = (_props: { 228 + schema: SchemaWithType<'null'>; 229 + }): Omit<ZodSchema, 'typeName'> => { 230 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 231 + result.expression = compiler.callExpression({ 218 232 functionName: compiler.propertyAccessExpression({ 219 233 expression: identifiers.z, 220 234 name: identifiers.null, 221 235 }), 222 236 }); 223 - return expression; 237 + return result as Omit<ZodSchema, 'typeName'>; 224 238 }; 225 239 226 240 const numberParameter = ({ ··· 229 243 }: { 230 244 isBigInt: boolean; 231 245 value: unknown; 232 - }) => { 246 + }): ts.Expression | undefined => { 233 247 const expression = compiler.valueToExpression({ value }); 234 248 235 249 if ( ··· 252 266 schema, 253 267 }: { 254 268 schema: SchemaWithType<'integer' | 'number'>; 255 - }) => { 269 + }): Omit<ZodSchema, 'typeName'> => { 270 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 271 + 256 272 const isBigInt = schema.type === 'integer' && schema.format === 'int64'; 257 273 258 274 if (typeof schema.const === 'number') { 259 275 // TODO: parser - handle bigint constants 260 - const expression = compiler.callExpression({ 276 + result.expression = compiler.callExpression({ 261 277 functionName: compiler.propertyAccessExpression({ 262 278 expression: identifiers.z, 263 279 name: identifiers.literal, 264 280 }), 265 281 parameters: [compiler.ots.number(schema.const)], 266 282 }); 267 - return expression; 283 + return result as Omit<ZodSchema, 'typeName'>; 268 284 } 269 285 270 - let numberExpression = compiler.callExpression({ 286 + result.expression = compiler.callExpression({ 271 287 functionName: isBigInt 272 288 ? compiler.propertyAccessExpression({ 273 289 expression: compiler.propertyAccessExpression({ ··· 283 299 }); 284 300 285 301 if (!isBigInt && schema.type === 'integer') { 286 - numberExpression = compiler.callExpression({ 302 + result.expression = compiler.callExpression({ 287 303 functionName: compiler.propertyAccessExpression({ 288 304 expression: identifiers.z, 289 305 name: identifiers.int, ··· 292 308 } 293 309 294 310 if (schema.exclusiveMinimum !== undefined) { 295 - numberExpression = compiler.callExpression({ 311 + result.expression = compiler.callExpression({ 296 312 functionName: compiler.propertyAccessExpression({ 297 - expression: numberExpression, 313 + expression: result.expression, 298 314 name: identifiers.gt, 299 315 }), 300 316 parameters: [ ··· 302 318 ], 303 319 }); 304 320 } else if (schema.minimum !== undefined) { 305 - numberExpression = compiler.callExpression({ 321 + result.expression = compiler.callExpression({ 306 322 functionName: compiler.propertyAccessExpression({ 307 - expression: numberExpression, 323 + expression: result.expression, 308 324 name: identifiers.gte, 309 325 }), 310 326 parameters: [numberParameter({ isBigInt, value: schema.minimum })], ··· 312 328 } 313 329 314 330 if (schema.exclusiveMaximum !== undefined) { 315 - numberExpression = compiler.callExpression({ 331 + result.expression = compiler.callExpression({ 316 332 functionName: compiler.propertyAccessExpression({ 317 - expression: numberExpression, 333 + expression: result.expression, 318 334 name: identifiers.lt, 319 335 }), 320 336 parameters: [ ··· 322 338 ], 323 339 }); 324 340 } else if (schema.maximum !== undefined) { 325 - numberExpression = compiler.callExpression({ 341 + result.expression = compiler.callExpression({ 326 342 functionName: compiler.propertyAccessExpression({ 327 - expression: numberExpression, 343 + expression: result.expression, 328 344 name: identifiers.lte, 329 345 }), 330 346 parameters: [numberParameter({ isBigInt, value: schema.maximum })], 331 347 }); 332 348 } 333 349 334 - return numberExpression; 350 + return result as Omit<ZodSchema, 'typeName'>; 335 351 }; 336 352 337 353 const objectTypeToZodSchema = ({ ··· 342 358 plugin: ZodPlugin['Instance']; 343 359 schema: SchemaWithType<'object'>; 344 360 state: State; 345 - }): { 346 - expression: ts.CallExpression; 347 - } => { 361 + }): Omit<ZodSchema, 'typeName'> => { 362 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 363 + 348 364 // TODO: parser - handle constants 349 - const properties: Array<ts.PropertyAssignment> = []; 365 + const properties: Array<ts.PropertyAssignment | ts.GetAccessorDeclaration> = 366 + []; 350 367 351 368 const required = schema.required ?? []; 352 369 ··· 354 371 const property = schema.properties[name]!; 355 372 const isRequired = required.includes(name); 356 373 357 - const propertyExpression = schemaToZodSchema({ 374 + const propertySchema = schemaToZodSchema({ 358 375 optional: !isRequired, 359 376 plugin, 360 377 schema: property, 361 378 state, 362 - }).expression; 379 + }); 380 + if (propertySchema.hasCircularReference) { 381 + result.hasCircularReference = true; 382 + } 363 383 364 384 numberRegExp.lastIndex = 0; 365 385 let propertyName; ··· 380 400 ) { 381 401 propertyName = `'${name}'`; 382 402 } 383 - properties.push( 384 - compiler.propertyAssignment({ 385 - initializer: propertyExpression, 386 - name: propertyName, 387 - }), 388 - ); 403 + 404 + if (propertySchema.hasCircularReference) { 405 + properties.push( 406 + compiler.getAccessorDeclaration({ 407 + name: propertyName, 408 + // @ts-expect-error 409 + returnType: propertySchema.typeName 410 + ? compiler.propertyAccessExpression({ 411 + expression: identifiers.z, 412 + name: propertySchema.typeName, 413 + }) 414 + : undefined, 415 + statements: [ 416 + compiler.returnStatement({ 417 + expression: propertySchema.expression, 418 + }), 419 + ], 420 + }), 421 + ); 422 + } else { 423 + properties.push( 424 + compiler.propertyAssignment({ 425 + initializer: propertySchema.expression, 426 + name: propertyName, 427 + }), 428 + ); 429 + } 389 430 } 390 431 391 432 if ( ··· 397 438 plugin, 398 439 schema: schema.additionalProperties, 399 440 state, 400 - }).expression; 401 - const expression = compiler.callExpression({ 441 + }); 442 + result.expression = compiler.callExpression({ 402 443 functionName: compiler.propertyAccessExpression({ 403 444 expression: identifiers.z, 404 445 name: identifiers.record, ··· 411 452 }), 412 453 parameters: [], 413 454 }), 414 - zodSchema, 455 + zodSchema.expression, 415 456 ], 416 457 }); 417 - return { 418 - expression, 419 - }; 458 + if (zodSchema.hasCircularReference) { 459 + result.hasCircularReference = true; 460 + } 461 + return result as Omit<ZodSchema, 'typeName'>; 420 462 } 421 463 422 - const expression = compiler.callExpression({ 464 + result.expression = compiler.callExpression({ 423 465 functionName: compiler.propertyAccessExpression({ 424 466 expression: identifiers.z, 425 467 name: identifiers.object, 426 468 }), 427 469 parameters: [ts.factory.createObjectLiteralExpression(properties, true)], 428 470 }); 429 - return { 430 - expression, 431 - }; 471 + 472 + return result as Omit<ZodSchema, 'typeName'>; 432 473 }; 433 474 434 475 const stringTypeToZodSchema = ({ ··· 437 478 }: { 438 479 plugin: ZodPlugin['Instance']; 439 480 schema: SchemaWithType<'string'>; 440 - }) => { 481 + }): Omit<ZodSchema, 'typeName'> => { 482 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 483 + 441 484 if (typeof schema.const === 'string') { 442 - const expression = compiler.callExpression({ 485 + result.expression = compiler.callExpression({ 443 486 functionName: compiler.propertyAccessExpression({ 444 487 expression: identifiers.z, 445 488 name: identifiers.literal, 446 489 }), 447 490 parameters: [compiler.ots.string(schema.const)], 448 491 }); 449 - return expression; 492 + return result as Omit<ZodSchema, 'typeName'>; 450 493 } 451 494 452 - let stringExpression = compiler.callExpression({ 495 + result.expression = compiler.callExpression({ 453 496 functionName: compiler.propertyAccessExpression({ 454 497 expression: identifiers.z, 455 498 name: identifiers.string, ··· 459 502 if (schema.format) { 460 503 switch (schema.format) { 461 504 case 'date': 462 - stringExpression = compiler.callExpression({ 505 + result.expression = compiler.callExpression({ 463 506 functionName: compiler.propertyAccessExpression({ 464 507 expression: compiler.propertyAccessExpression({ 465 508 expression: identifiers.z, ··· 470 513 }); 471 514 break; 472 515 case 'date-time': 473 - stringExpression = compiler.callExpression({ 516 + result.expression = compiler.callExpression({ 474 517 functionName: compiler.propertyAccessExpression({ 475 518 expression: compiler.propertyAccessExpression({ 476 519 expression: identifiers.z, ··· 493 536 }); 494 537 break; 495 538 case 'email': 496 - stringExpression = compiler.callExpression({ 539 + result.expression = compiler.callExpression({ 497 540 functionName: compiler.propertyAccessExpression({ 498 541 expression: identifiers.z, 499 542 name: identifiers.email, ··· 501 544 }); 502 545 break; 503 546 case 'ipv4': 504 - stringExpression = compiler.callExpression({ 547 + result.expression = compiler.callExpression({ 505 548 functionName: compiler.propertyAccessExpression({ 506 549 expression: identifiers.z, 507 550 name: identifiers.ipv4, ··· 509 552 }); 510 553 break; 511 554 case 'ipv6': 512 - stringExpression = compiler.callExpression({ 555 + result.expression = compiler.callExpression({ 513 556 functionName: compiler.propertyAccessExpression({ 514 557 expression: identifiers.z, 515 558 name: identifiers.ipv6, ··· 517 560 }); 518 561 break; 519 562 case 'time': 520 - stringExpression = compiler.callExpression({ 563 + result.expression = compiler.callExpression({ 521 564 functionName: compiler.propertyAccessExpression({ 522 565 expression: compiler.propertyAccessExpression({ 523 566 expression: identifiers.z, ··· 528 571 }); 529 572 break; 530 573 case 'uri': 531 - stringExpression = compiler.callExpression({ 574 + result.expression = compiler.callExpression({ 532 575 functionName: compiler.propertyAccessExpression({ 533 576 expression: identifiers.z, 534 577 name: identifiers.url, ··· 536 579 }); 537 580 break; 538 581 case 'uuid': 539 - stringExpression = compiler.callExpression({ 582 + result.expression = compiler.callExpression({ 540 583 functionName: compiler.propertyAccessExpression({ 541 584 expression: identifiers.z, 542 585 name: identifiers.uuid, ··· 547 590 } 548 591 549 592 if (schema.minLength === schema.maxLength && schema.minLength !== undefined) { 550 - stringExpression = compiler.callExpression({ 593 + result.expression = compiler.callExpression({ 551 594 functionName: compiler.propertyAccessExpression({ 552 - expression: stringExpression, 595 + expression: result.expression, 553 596 name: identifiers.length, 554 597 }), 555 598 parameters: [compiler.valueToExpression({ value: schema.minLength })], 556 599 }); 557 600 } else { 558 601 if (schema.minLength !== undefined) { 559 - stringExpression = compiler.callExpression({ 602 + result.expression = compiler.callExpression({ 560 603 functionName: compiler.propertyAccessExpression({ 561 - expression: stringExpression, 604 + expression: result.expression, 562 605 name: identifiers.min, 563 606 }), 564 607 parameters: [compiler.valueToExpression({ value: schema.minLength })], ··· 566 609 } 567 610 568 611 if (schema.maxLength !== undefined) { 569 - stringExpression = compiler.callExpression({ 612 + result.expression = compiler.callExpression({ 570 613 functionName: compiler.propertyAccessExpression({ 571 - expression: stringExpression, 614 + expression: result.expression, 572 615 name: identifiers.max, 573 616 }), 574 617 parameters: [compiler.valueToExpression({ value: schema.maxLength })], ··· 577 620 } 578 621 579 622 if (schema.pattern) { 580 - stringExpression = compiler.callExpression({ 623 + result.expression = compiler.callExpression({ 581 624 functionName: compiler.propertyAccessExpression({ 582 - expression: stringExpression, 625 + expression: result.expression, 583 626 name: identifiers.regex, 584 627 }), 585 628 parameters: [compiler.regularExpressionLiteral({ text: schema.pattern })], 586 629 }); 587 630 } 588 631 589 - return stringExpression; 632 + return result as Omit<ZodSchema, 'typeName'>; 590 633 }; 591 634 592 635 const tupleTypeToZodSchema = ({ ··· 597 640 plugin: ZodPlugin['Instance']; 598 641 schema: SchemaWithType<'tuple'>; 599 642 state: State; 600 - }) => { 643 + }): Omit<ZodSchema, 'typeName'> => { 644 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 645 + 601 646 if (schema.const && Array.isArray(schema.const)) { 602 647 const tupleElements = schema.const.map((value) => 603 648 compiler.callExpression({ ··· 608 653 parameters: [compiler.valueToExpression({ value })], 609 654 }), 610 655 ); 611 - const expression = compiler.callExpression({ 656 + result.expression = compiler.callExpression({ 612 657 functionName: compiler.propertyAccessExpression({ 613 658 expression: identifiers.z, 614 659 name: identifiers.tuple, ··· 619 664 }), 620 665 ], 621 666 }); 622 - return expression; 667 + return result as Omit<ZodSchema, 'typeName'>; 623 668 } 624 669 625 670 const tupleElements: Array<ts.Expression> = []; 626 671 627 672 for (const item of schema.items ?? []) { 628 - tupleElements.push( 629 - schemaToZodSchema({ 630 - plugin, 631 - schema: item, 632 - state, 633 - }).expression, 634 - ); 673 + const itemSchema = schemaToZodSchema({ 674 + plugin, 675 + schema: item, 676 + state, 677 + }); 678 + tupleElements.push(itemSchema.expression); 679 + 680 + if (itemSchema.hasCircularReference) { 681 + result.hasCircularReference = true; 682 + } 635 683 } 636 684 637 - const expression = compiler.callExpression({ 685 + result.expression = compiler.callExpression({ 638 686 functionName: compiler.propertyAccessExpression({ 639 687 expression: identifiers.z, 640 688 name: identifiers.tuple, ··· 645 693 }), 646 694 ], 647 695 }); 648 - return expression; 696 + 697 + return result as Omit<ZodSchema, 'typeName'>; 649 698 }; 650 699 651 700 // eslint-disable-next-line @typescript-eslint/no-unused-vars 652 701 const undefinedTypeToZodSchema = (_props: { 653 702 schema: SchemaWithType<'undefined'>; 654 - }) => { 655 - const expression = compiler.callExpression({ 703 + }): Omit<ZodSchema, 'typeName'> => { 704 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 705 + result.expression = compiler.callExpression({ 656 706 functionName: compiler.propertyAccessExpression({ 657 707 expression: identifiers.z, 658 708 name: identifiers.undefined, 659 709 }), 660 710 }); 661 - return expression; 711 + return result as Omit<ZodSchema, 'typeName'>; 662 712 }; 663 713 664 714 // eslint-disable-next-line @typescript-eslint/no-unused-vars 665 715 const unknownTypeToZodSchema = (_props: { 666 716 schema: SchemaWithType<'unknown'>; 667 - }) => { 668 - const expression = compiler.callExpression({ 717 + }): Omit<ZodSchema, 'typeName'> => { 718 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 719 + result.expression = compiler.callExpression({ 669 720 functionName: compiler.propertyAccessExpression({ 670 721 expression: identifiers.z, 671 722 name: identifiers.unknown, 672 723 }), 673 724 }); 674 - return expression; 725 + return result as Omit<ZodSchema, 'typeName'>; 675 726 }; 676 727 677 728 // eslint-disable-next-line @typescript-eslint/no-unused-vars 678 - const voidTypeToZodSchema = (_props: { schema: SchemaWithType<'void'> }) => { 679 - const expression = compiler.callExpression({ 729 + const voidTypeToZodSchema = (_props: { 730 + schema: SchemaWithType<'void'>; 731 + }): Omit<ZodSchema, 'typeName'> => { 732 + const result: Partial<Omit<ZodSchema, 'typeName'>> = {}; 733 + result.expression = compiler.callExpression({ 680 734 functionName: compiler.propertyAccessExpression({ 681 735 expression: identifiers.z, 682 736 name: identifiers.void, 683 737 }), 684 738 }); 685 - return expression; 739 + return result as Omit<ZodSchema, 'typeName'>; 686 740 }; 687 741 688 742 const schemaTypeToZodSchema = ({ ··· 693 747 plugin: ZodPlugin['Instance']; 694 748 schema: IR.SchemaObject; 695 749 state: State; 696 - }): { 697 - expression: ts.Expression; 698 - } => { 750 + }): Omit<ZodSchema, 'typeName'> => { 699 751 switch (schema.type as Required<IR.SchemaObject>['type']) { 700 752 case 'array': 701 - return { 702 - expression: arrayTypeToZodSchema({ 703 - plugin, 704 - schema: schema as SchemaWithType<'array'>, 705 - state, 706 - }), 707 - }; 753 + return arrayTypeToZodSchema({ 754 + plugin, 755 + schema: schema as SchemaWithType<'array'>, 756 + state, 757 + }); 708 758 case 'boolean': 709 - return { 710 - expression: booleanTypeToZodSchema({ 711 - schema: schema as SchemaWithType<'boolean'>, 712 - }), 713 - }; 759 + return booleanTypeToZodSchema({ 760 + schema: schema as SchemaWithType<'boolean'>, 761 + }); 714 762 case 'enum': 715 - return { 716 - expression: enumTypeToZodSchema({ 717 - schema: schema as SchemaWithType<'enum'>, 718 - }), 719 - }; 763 + return enumTypeToZodSchema({ 764 + schema: schema as SchemaWithType<'enum'>, 765 + }); 720 766 case 'integer': 721 767 case 'number': 722 - return { 723 - expression: numberTypeToZodSchema({ 724 - schema: schema as SchemaWithType<'integer' | 'number'>, 725 - }), 726 - }; 768 + return numberTypeToZodSchema({ 769 + schema: schema as SchemaWithType<'integer' | 'number'>, 770 + }); 727 771 case 'never': 728 - return { 729 - expression: neverTypeToZodSchema({ 730 - schema: schema as SchemaWithType<'never'>, 731 - }), 732 - }; 772 + return neverTypeToZodSchema({ 773 + schema: schema as SchemaWithType<'never'>, 774 + }); 733 775 case 'null': 734 - return { 735 - expression: nullTypeToZodSchema({ 736 - schema: schema as SchemaWithType<'null'>, 737 - }), 738 - }; 776 + return nullTypeToZodSchema({ 777 + schema: schema as SchemaWithType<'null'>, 778 + }); 739 779 case 'object': 740 780 return objectTypeToZodSchema({ 741 781 plugin, ··· 743 783 state, 744 784 }); 745 785 case 'string': 746 - return { 747 - expression: stringTypeToZodSchema({ 748 - plugin, 749 - schema: schema as SchemaWithType<'string'>, 750 - }), 751 - }; 786 + return stringTypeToZodSchema({ 787 + plugin, 788 + schema: schema as SchemaWithType<'string'>, 789 + }); 752 790 case 'tuple': 753 - return { 754 - expression: tupleTypeToZodSchema({ 755 - plugin, 756 - schema: schema as SchemaWithType<'tuple'>, 757 - state, 758 - }), 759 - }; 791 + return tupleTypeToZodSchema({ 792 + plugin, 793 + schema: schema as SchemaWithType<'tuple'>, 794 + state, 795 + }); 760 796 case 'undefined': 761 - return { 762 - expression: undefinedTypeToZodSchema({ 763 - schema: schema as SchemaWithType<'undefined'>, 764 - }), 765 - }; 797 + return undefinedTypeToZodSchema({ 798 + schema: schema as SchemaWithType<'undefined'>, 799 + }); 766 800 case 'unknown': 767 - return { 768 - expression: unknownTypeToZodSchema({ 769 - schema: schema as SchemaWithType<'unknown'>, 770 - }), 771 - }; 801 + return unknownTypeToZodSchema({ 802 + schema: schema as SchemaWithType<'unknown'>, 803 + }); 772 804 case 'void': 773 - return { 774 - expression: voidTypeToZodSchema({ 775 - schema: schema as SchemaWithType<'void'>, 776 - }), 777 - }; 805 + return voidTypeToZodSchema({ 806 + schema: schema as SchemaWithType<'void'>, 807 + }); 778 808 } 779 809 }; 780 810 ··· 802 832 const isCircularReference = state.circularReferenceTracker.includes( 803 833 schema.$ref, 804 834 ); 835 + const isSelfReference = state.currentReferenceTracker.includes(schema.$ref); 805 836 state.circularReferenceTracker.push(schema.$ref); 837 + state.currentReferenceTracker.push(schema.$ref); 806 838 807 839 const id = plugin.api.getId({ type: 'ref', value: schema.$ref }); 808 840 ··· 810 842 const expression = file.addNodeReference(id, { 811 843 factory: (text) => compiler.identifier({ text }), 812 844 }); 813 - zodSchema.expression = compiler.callExpression({ 814 - functionName: compiler.propertyAccessExpression({ 815 - expression: identifiers.z, 816 - name: identifiers.lazy, 817 - }), 818 - parameters: [ 819 - compiler.arrowFunction({ 820 - statements: [compiler.returnStatement({ expression })], 845 + if (isSelfReference) { 846 + zodSchema.expression = compiler.callExpression({ 847 + functionName: compiler.propertyAccessExpression({ 848 + expression: identifiers.z, 849 + name: identifiers.lazy, 821 850 }), 822 - ], 823 - }); 851 + parameters: [ 852 + compiler.arrowFunction({ 853 + returnType: compiler.keywordTypeNode({ keyword: 'any' }), 854 + statements: [compiler.returnStatement({ expression })], 855 + }), 856 + ], 857 + }); 858 + } else { 859 + zodSchema.expression = expression; 860 + } 861 + zodSchema.hasCircularReference = true; 824 862 } else if (!file.getName(id)) { 825 863 // if $ref hasn't been processed yet, inline it to avoid the 826 864 // "Block-scoped variable used before its declaration." error ··· 842 880 } 843 881 844 882 state.circularReferenceTracker.pop(); 883 + state.currentReferenceTracker.pop(); 845 884 } else if (schema.type) { 846 885 const zSchema = schemaTypeToZodSchema({ plugin, schema, state }); 847 886 zodSchema.expression = zSchema.expression; 887 + zodSchema.hasCircularReference = zSchema.hasCircularReference; 848 888 849 889 if (plugin.config.metadata && schema.description) { 850 890 zodSchema.expression = compiler.callExpression({ ··· 955 995 }), 956 996 parameters: [zodSchema.expression], 957 997 }); 998 + zodSchema.typeName = identifiers.ZodOptional; 958 999 } 959 1000 960 1001 if (schema.default !== undefined) { ··· 982 1023 id, 983 1024 plugin, 984 1025 schema, 985 - state, 1026 + state: _state, 986 1027 }: { 987 1028 id: string; 988 1029 plugin: ZodPlugin['Instance']; 989 1030 schema: IR.SchemaObject; 990 - state?: State; 1031 + state?: Omit<State, 'currentReferenceTracker'>; 991 1032 }): void => { 992 - if (!state) { 993 - state = { 994 - circularReferenceTracker: [id], 995 - hasCircularReference: false, 996 - }; 997 - } 1033 + const state: State = { 1034 + circularReferenceTracker: [id], 1035 + hasCircularReference: false, 1036 + ..._state, 1037 + currentReferenceTracker: [id], 1038 + }; 998 1039 999 1040 const file = plugin.context.file({ id: zodId })!; 1000 1041 const schemaId = plugin.api.getId({ type: 'ref', value: id }); ··· 1049 1090 getZodSchema: (schema) => { 1050 1091 const state: State = { 1051 1092 circularReferenceTracker: [], 1093 + currentReferenceTracker: [], 1052 1094 hasCircularReference: false, 1053 1095 }; 1054 1096 return schemaToZodSchema({ plugin, schema, state });
+15
pnpm-lock.yaml
··· 998 998 specifier: 3.25.3 999 999 version: 3.25.3 1000 1000 1001 + packages/openapi-ts-tests/zod/v4: 1002 + devDependencies: 1003 + '@config/vite-base': 1004 + specifier: workspace:* 1005 + version: link:../../../config-vite-base 1006 + '@hey-api/openapi-ts': 1007 + specifier: workspace:* 1008 + version: link:../../../openapi-ts 1009 + typescript: 1010 + specifier: 5.8.3 1011 + version: 5.8.3 1012 + zod: 1013 + specifier: 4.0.5 1014 + version: 4.0.5 1015 + 1001 1016 packages/vite-plugin: 1002 1017 devDependencies: 1003 1018 '@hey-api/openapi-ts':