@kubb/plugin-zod 0.0.0-canary-20241104172400

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +53 -0
  3. package/dist/chunk-37OP7TSO.cjs +354 -0
  4. package/dist/chunk-37OP7TSO.cjs.map +1 -0
  5. package/dist/chunk-OOAUU32I.js +235 -0
  6. package/dist/chunk-OOAUU32I.js.map +1 -0
  7. package/dist/chunk-QEYWJ6VH.cjs +244 -0
  8. package/dist/chunk-QEYWJ6VH.cjs.map +1 -0
  9. package/dist/chunk-SSOO3TXR.js +347 -0
  10. package/dist/chunk-SSOO3TXR.js.map +1 -0
  11. package/dist/components.cjs +16 -0
  12. package/dist/components.cjs.map +1 -0
  13. package/dist/components.d.cts +29 -0
  14. package/dist/components.d.ts +29 -0
  15. package/dist/components.js +3 -0
  16. package/dist/components.js.map +1 -0
  17. package/dist/generators.cjs +17 -0
  18. package/dist/generators.cjs.map +1 -0
  19. package/dist/generators.d.cts +10 -0
  20. package/dist/generators.d.ts +10 -0
  21. package/dist/generators.js +4 -0
  22. package/dist/generators.js.map +1 -0
  23. package/dist/index.cjs +17 -0
  24. package/dist/index.cjs.map +1 -0
  25. package/dist/index.d.cts +9 -0
  26. package/dist/index.d.ts +9 -0
  27. package/dist/index.js +4 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/types-L1fXCZAs.d.cts +100 -0
  30. package/dist/types-L1fXCZAs.d.ts +100 -0
  31. package/package.json +95 -0
  32. package/src/components/Operations.tsx +49 -0
  33. package/src/components/Zod.tsx +68 -0
  34. package/src/components/index.ts +2 -0
  35. package/src/generators/__snapshots__/anyof.ts +3 -0
  36. package/src/generators/__snapshots__/coercion.ts +3 -0
  37. package/src/generators/__snapshots__/coercionDates.ts +3 -0
  38. package/src/generators/__snapshots__/coercionNumbers.ts +3 -0
  39. package/src/generators/__snapshots__/coercionStrings.ts +3 -0
  40. package/src/generators/__snapshots__/createPet.ts +15 -0
  41. package/src/generators/__snapshots__/createPetWithUnknownTypeAny.ts +13 -0
  42. package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown.ts +15 -0
  43. package/src/generators/__snapshots__/deletePet.ts +3 -0
  44. package/src/generators/__snapshots__/discriminator.ts +3 -0
  45. package/src/generators/__snapshots__/enumBooleanLiteral.ts +3 -0
  46. package/src/generators/__snapshots__/enumNamesType.ts +3 -0
  47. package/src/generators/__snapshots__/enumNullable.ts +3 -0
  48. package/src/generators/__snapshots__/enumSingleLiteral.ts +3 -0
  49. package/src/generators/__snapshots__/enumVarNamesType.ts +3 -0
  50. package/src/generators/__snapshots__/example.ts +3 -0
  51. package/src/generators/__snapshots__/getPets.ts +15 -0
  52. package/src/generators/__snapshots__/mixedValueTypeConst.ts +6 -0
  53. package/src/generators/__snapshots__/nullableString.ts +3 -0
  54. package/src/generators/__snapshots__/nullableStringUuid.ts +3 -0
  55. package/src/generators/__snapshots__/nullableStringWithAnyOf.ts +3 -0
  56. package/src/generators/__snapshots__/numberValueConst.ts +6 -0
  57. package/src/generators/__snapshots__/oneof.ts +3 -0
  58. package/src/generators/__snapshots__/operations.ts +43 -0
  59. package/src/generators/__snapshots__/optionalPetInfer.ts +5 -0
  60. package/src/generators/__snapshots__/optionalPetTyped.ts +3 -0
  61. package/src/generators/__snapshots__/order.ts +3 -0
  62. package/src/generators/__snapshots__/orderDateTyeString.ts +10 -0
  63. package/src/generators/__snapshots__/orderDateTypeFalse.ts +3 -0
  64. package/src/generators/__snapshots__/orderDateTypeString.ts +3 -0
  65. package/src/generators/__snapshots__/pet.ts +3 -0
  66. package/src/generators/__snapshots__/petArray.ts +6 -0
  67. package/src/generators/__snapshots__/petCoercion.ts +3 -0
  68. package/src/generators/__snapshots__/petTupleObject.ts +6 -0
  69. package/src/generators/__snapshots__/petWithMapper.ts +3 -0
  70. package/src/generators/__snapshots__/pets.ts +3 -0
  71. package/src/generators/__snapshots__/recursive.ts +3 -0
  72. package/src/generators/__snapshots__/showPetById.ts +15 -0
  73. package/src/generators/__snapshots__/stringValueConst.ts +6 -0
  74. package/src/generators/__snapshots__/uuidSchema.ts +3 -0
  75. package/src/generators/index.ts +2 -0
  76. package/src/generators/operationsGenerator.tsx +39 -0
  77. package/src/generators/zodGenerator.tsx +121 -0
  78. package/src/index.ts +2 -0
  79. package/src/parser/index.ts +381 -0
  80. package/src/plugin.ts +139 -0
  81. package/src/types.ts +106 -0
@@ -0,0 +1,100 @@
1
+ import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
2
+ import { SchemaObject } from '@kubb/oas';
3
+ import { ResolvePathOptions, Exclude, Include, Override, Schema, Generator } from '@kubb/plugin-oas';
4
+
5
+ type Options = {
6
+ /**
7
+ * @default 'zod'
8
+ */
9
+ output?: Output;
10
+ /**
11
+ * Group the Zod schemas based on the provided name.
12
+ */
13
+ group?: Group;
14
+ /**
15
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
16
+ */
17
+ exclude?: Array<Exclude>;
18
+ /**
19
+ * Array containing include parameters to include tags/operations/methods/paths.
20
+ */
21
+ include?: Array<Include>;
22
+ /**
23
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
24
+ */
25
+ override?: Array<Override<ResolvedOptions>>;
26
+ /**
27
+ * Path to Zod
28
+ * It will be used as `import { z } from '${importPath}'`.
29
+ * It allows both relative and absolute path.
30
+ * the path will be applied as is, so relative path should be based on the file being generated.
31
+ * @default 'zod'
32
+ */
33
+ importPath?: string;
34
+ /**
35
+ * Choose to use `date` or `datetime` as JavaScript `Date` instead of `string`.
36
+ * False will fallback on a simple z.string() format
37
+ * @default 'string' 'stringOffset' will become the default in Kubb v3
38
+ */
39
+ dateType?: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
40
+ /**
41
+ * Which type to use when the Swagger/OpenAPI file is not providing more information
42
+ * @default 'any'
43
+ */
44
+ unknownType?: 'any' | 'unknown';
45
+ /**
46
+ * Use TypeScript(`@kubb/plugin-ts`) to add type annotation.
47
+ */
48
+ typed?: boolean;
49
+ /**
50
+ * Return Zod generated schema as type with z.infer<TYPE>
51
+ */
52
+ inferred?: boolean;
53
+ /**
54
+ * Use of z.coerce.string() instead of z.string()
55
+ * can also be an object to enable coercion for dates, strings, and numbers
56
+ */
57
+ coercion?: boolean | {
58
+ dates?: boolean;
59
+ strings?: boolean;
60
+ numbers?: boolean;
61
+ };
62
+ operations?: boolean;
63
+ mapper?: Record<string, string>;
64
+ transformers?: {
65
+ /**
66
+ * Customize the names based on the type that is provided by the plugin.
67
+ */
68
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
69
+ /**
70
+ * Receive schema and baseName(propertName) and return FakerMeta array
71
+ * TODO TODO add docs
72
+ * @beta
73
+ */
74
+ schema?: (props: {
75
+ schema?: SchemaObject;
76
+ name?: string;
77
+ parentName?: string;
78
+ }, defaultSchemas: Schema[]) => Schema[] | undefined;
79
+ };
80
+ /**
81
+ * Define some generators next to the zod generators
82
+ */
83
+ generators?: Array<Generator<PluginZod>>;
84
+ };
85
+ type ResolvedOptions = {
86
+ output: Output;
87
+ override: NonNullable<Options['override']>;
88
+ transformers: NonNullable<Options['transformers']>;
89
+ dateType: NonNullable<Options['dateType']>;
90
+ unknownType: NonNullable<Options['unknownType']>;
91
+ typed: NonNullable<Options['typed']>;
92
+ inferred: NonNullable<Options['inferred']>;
93
+ mapper: NonNullable<Options['mapper']>;
94
+ importPath: NonNullable<Options['importPath']>;
95
+ coercion: NonNullable<Options['coercion']>;
96
+ operations: NonNullable<Options['operations']>;
97
+ };
98
+ type PluginZod = PluginFactoryOptions<'plugin-zod', Options, ResolvedOptions, never, ResolvePathOptions>;
99
+
100
+ export type { Options as O, PluginZod as P };
@@ -0,0 +1,100 @@
1
+ import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
2
+ import { SchemaObject } from '@kubb/oas';
3
+ import { ResolvePathOptions, Exclude, Include, Override, Schema, Generator } from '@kubb/plugin-oas';
4
+
5
+ type Options = {
6
+ /**
7
+ * @default 'zod'
8
+ */
9
+ output?: Output;
10
+ /**
11
+ * Group the Zod schemas based on the provided name.
12
+ */
13
+ group?: Group;
14
+ /**
15
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
16
+ */
17
+ exclude?: Array<Exclude>;
18
+ /**
19
+ * Array containing include parameters to include tags/operations/methods/paths.
20
+ */
21
+ include?: Array<Include>;
22
+ /**
23
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
24
+ */
25
+ override?: Array<Override<ResolvedOptions>>;
26
+ /**
27
+ * Path to Zod
28
+ * It will be used as `import { z } from '${importPath}'`.
29
+ * It allows both relative and absolute path.
30
+ * the path will be applied as is, so relative path should be based on the file being generated.
31
+ * @default 'zod'
32
+ */
33
+ importPath?: string;
34
+ /**
35
+ * Choose to use `date` or `datetime` as JavaScript `Date` instead of `string`.
36
+ * False will fallback on a simple z.string() format
37
+ * @default 'string' 'stringOffset' will become the default in Kubb v3
38
+ */
39
+ dateType?: false | 'string' | 'stringOffset' | 'stringLocal' | 'date';
40
+ /**
41
+ * Which type to use when the Swagger/OpenAPI file is not providing more information
42
+ * @default 'any'
43
+ */
44
+ unknownType?: 'any' | 'unknown';
45
+ /**
46
+ * Use TypeScript(`@kubb/plugin-ts`) to add type annotation.
47
+ */
48
+ typed?: boolean;
49
+ /**
50
+ * Return Zod generated schema as type with z.infer<TYPE>
51
+ */
52
+ inferred?: boolean;
53
+ /**
54
+ * Use of z.coerce.string() instead of z.string()
55
+ * can also be an object to enable coercion for dates, strings, and numbers
56
+ */
57
+ coercion?: boolean | {
58
+ dates?: boolean;
59
+ strings?: boolean;
60
+ numbers?: boolean;
61
+ };
62
+ operations?: boolean;
63
+ mapper?: Record<string, string>;
64
+ transformers?: {
65
+ /**
66
+ * Customize the names based on the type that is provided by the plugin.
67
+ */
68
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
69
+ /**
70
+ * Receive schema and baseName(propertName) and return FakerMeta array
71
+ * TODO TODO add docs
72
+ * @beta
73
+ */
74
+ schema?: (props: {
75
+ schema?: SchemaObject;
76
+ name?: string;
77
+ parentName?: string;
78
+ }, defaultSchemas: Schema[]) => Schema[] | undefined;
79
+ };
80
+ /**
81
+ * Define some generators next to the zod generators
82
+ */
83
+ generators?: Array<Generator<PluginZod>>;
84
+ };
85
+ type ResolvedOptions = {
86
+ output: Output;
87
+ override: NonNullable<Options['override']>;
88
+ transformers: NonNullable<Options['transformers']>;
89
+ dateType: NonNullable<Options['dateType']>;
90
+ unknownType: NonNullable<Options['unknownType']>;
91
+ typed: NonNullable<Options['typed']>;
92
+ inferred: NonNullable<Options['inferred']>;
93
+ mapper: NonNullable<Options['mapper']>;
94
+ importPath: NonNullable<Options['importPath']>;
95
+ coercion: NonNullable<Options['coercion']>;
96
+ operations: NonNullable<Options['operations']>;
97
+ };
98
+ type PluginZod = PluginFactoryOptions<'plugin-zod', Options, ResolvedOptions, never, ResolvePathOptions>;
99
+
100
+ export type { Options as O, PluginZod as P };
package/package.json ADDED
@@ -0,0 +1,95 @@
1
+ {
2
+ "name": "@kubb/plugin-zod",
3
+ "version": "0.0.0-canary-20241104172400",
4
+ "description": "Generator plugin-zod",
5
+ "keywords": [
6
+ "typescript",
7
+ "plugins",
8
+ "kubb",
9
+ "codegen",
10
+ "swagger",
11
+ "openapi"
12
+ ],
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git://github.com/kubb-labs/kubb.git",
16
+ "directory": "packages/plugin-zod"
17
+ },
18
+ "license": "MIT",
19
+ "author": "Stijn Van Hulle <stijn@stijnvanhulle.be",
20
+ "sideEffects": false,
21
+ "type": "module",
22
+ "exports": {
23
+ ".": {
24
+ "import": "./dist/index.js",
25
+ "require": "./dist/index.cjs",
26
+ "default": "./dist/index.cjs"
27
+ },
28
+ "./generators": {
29
+ "import": "./dist/generators.js",
30
+ "require": "./dist/generators.cjs",
31
+ "default": "./dist/generators.cjs"
32
+ },
33
+ "./components": {
34
+ "import": "./dist/components.js",
35
+ "require": "./dist/components.cjs",
36
+ "default": "./dist/components.cjs"
37
+ },
38
+ "./package.json": "./package.json",
39
+ "./*": "./*"
40
+ },
41
+ "main": "dist/index.cjs",
42
+ "module": "dist/index.js",
43
+ "types": "./dist/index.d.ts",
44
+ "typesVersions": {
45
+ "*": {
46
+ "components": [
47
+ "./dist/components.d.ts"
48
+ ],
49
+ "generators": [
50
+ "./dist/generators.d.ts"
51
+ ]
52
+ }
53
+ },
54
+ "files": [
55
+ "src",
56
+ "dist",
57
+ "!/**/**.test.**",
58
+ "!/**/__tests__/**"
59
+ ],
60
+ "dependencies": {
61
+ "@kubb/core": "0.0.0-canary-20241104172400",
62
+ "@kubb/fs": "0.0.0-canary-20241104172400",
63
+ "@kubb/oas": "0.0.0-canary-20241104172400",
64
+ "@kubb/parser-ts": "0.0.0-canary-20241104172400",
65
+ "@kubb/plugin-oas": "0.0.0-canary-20241104172400",
66
+ "@kubb/plugin-ts": "0.0.0-canary-20241104172400",
67
+ "@kubb/react": "0.0.0-canary-20241104172400"
68
+ },
69
+ "devDependencies": {
70
+ "tsup": "^8.3.5",
71
+ "@kubb/config-ts": "0.0.0-canary-20241104172400",
72
+ "@kubb/config-tsup": "0.0.0-canary-20241104172400"
73
+ },
74
+ "peerDependencies": {
75
+ "@kubb/react": "0.0.0-canary-20241104172400"
76
+ },
77
+ "engines": {
78
+ "node": ">=20"
79
+ },
80
+ "publishConfig": {
81
+ "access": "public",
82
+ "registry": "https://registry.npmjs.org/"
83
+ },
84
+ "scripts": {
85
+ "build": "tsup",
86
+ "clean": "npx rimraf ./dist",
87
+ "lint": "bun biome lint .",
88
+ "lint:fix": "bun biome lint --apply-unsafe .",
89
+ "release": "pnpm publish --no-git-check",
90
+ "release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
91
+ "start": "tsup --watch",
92
+ "test": "vitest --passWithNoTests",
93
+ "typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
94
+ }
95
+ }
@@ -0,0 +1,49 @@
1
+ import type { SchemaNames } from '@kubb/plugin-oas/hooks'
2
+ import { Const, File } from '@kubb/react'
3
+
4
+ import transformers from '@kubb/core/transformers'
5
+ import type { HttpMethod, Operation } from '@kubb/oas'
6
+ import type { KubbNode } from '@kubb/react/types'
7
+
8
+ type Props = {
9
+ name: string
10
+ operations: Array<{ operation: Operation; data: SchemaNames }>
11
+ }
12
+
13
+ export function Operations({ name, operations }: Props): KubbNode {
14
+ const operationsJSON = operations.reduce(
15
+ (prev, acc) => {
16
+ prev[`"${acc.operation.getOperationId()}"`] = acc.data
17
+
18
+ return prev
19
+ },
20
+ {} as Record<string, unknown>,
21
+ )
22
+
23
+ const pathsJSON = operations.reduce(
24
+ (prev, acc) => {
25
+ prev[`"${acc.operation.path}"`] = {
26
+ ...(prev[`"${acc.operation.path}"`] || ({} as Record<HttpMethod, string>)),
27
+ [acc.operation.method]: `operations["${acc.operation.getOperationId()}"]`,
28
+ }
29
+
30
+ return prev
31
+ },
32
+ {} as Record<string, Record<HttpMethod, string>>,
33
+ )
34
+
35
+ return (
36
+ <>
37
+ <File.Source name={name} isExportable isIndexable>
38
+ <Const export name={name} asConst>
39
+ {`{${transformers.stringifyObject(operationsJSON)}}`}
40
+ </Const>
41
+ </File.Source>
42
+ <File.Source name={'paths'} isExportable isIndexable>
43
+ <Const export name={'paths'} asConst>
44
+ {`{${transformers.stringifyObject(pathsJSON)}}`}
45
+ </Const>
46
+ </File.Source>
47
+ </>
48
+ )
49
+ }
@@ -0,0 +1,68 @@
1
+ import transformers from '@kubb/core/transformers'
2
+ import { type Schema, schemaKeywords } from '@kubb/plugin-oas'
3
+ import { isKeyword } from '@kubb/plugin-oas'
4
+ import { Const, File, Type } from '@kubb/react'
5
+ import type { KubbNode } from '@kubb/react/types'
6
+ import * as parserZod from '../parser/index.ts'
7
+ import type { PluginZod } from '../types.ts'
8
+
9
+ type Props = {
10
+ name: string
11
+ typeName?: string
12
+ inferTypeName?: string
13
+ tree: Array<Schema>
14
+ description?: string
15
+ coercion: PluginZod['resolvedOptions']['coercion']
16
+ mapper: PluginZod['resolvedOptions']['mapper']
17
+ keysToOmit?: string[]
18
+ }
19
+
20
+ export function Zod({ name, typeName, tree, inferTypeName, mapper, coercion, keysToOmit, description }: Props): KubbNode {
21
+ const hasTuple = tree.some((item) => isKeyword(item, schemaKeywords.tuple))
22
+
23
+ const output = parserZod
24
+ .sort(tree)
25
+ .filter((item) => {
26
+ if (hasTuple && (isKeyword(item, schemaKeywords.min) || isKeyword(item, schemaKeywords.max))) {
27
+ return false
28
+ }
29
+
30
+ return true
31
+ })
32
+ .map((schema, _index, siblings) =>
33
+ parserZod.parse({ parent: undefined, current: schema, siblings }, { name, keysToOmit, typeName: typeName, description, mapper, coercion }),
34
+ )
35
+ .filter(Boolean)
36
+ .join('')
37
+
38
+ const suffix = output.endsWith('.nullable()') ? '.unwrap().and' : '.and'
39
+
40
+ return (
41
+ <>
42
+ <File.Source name={name} isExportable isIndexable>
43
+ <Const
44
+ export
45
+ name={name}
46
+ JSDoc={{
47
+ comments: [description ? `@description ${transformers.jsStringEscape(description)}` : undefined].filter(Boolean),
48
+ }}
49
+ >
50
+ {[
51
+ output,
52
+ keysToOmit?.length ? `${suffix}(z.object({ ${keysToOmit.map((key) => `${key}: z.never()`).join(',')} }))` : undefined,
53
+ typeName ? ` as z.ZodType<${typeName}>` : '',
54
+ ]
55
+ .filter(Boolean)
56
+ .join('') || 'z.undefined()'}
57
+ </Const>
58
+ </File.Source>
59
+ {inferTypeName && (
60
+ <File.Source name={inferTypeName} isExportable isIndexable isTypeOnly>
61
+ <Type export name={inferTypeName}>
62
+ {`z.infer<typeof ${name}>`}
63
+ </Type>
64
+ </File.Source>
65
+ )}
66
+ </>
67
+ )
68
+ }
@@ -0,0 +1,2 @@
1
+ export { Operations } from './Operations.tsx'
2
+ export { Zod } from './Zod.tsx'
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+
3
+ export const test = z.union([z.object({ "propertyA": z.string() }).strict(), z.object({ "propertyA": z.string(), "propertyB": z.string() }).strict()]);
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+
3
+ export const pet = z.object({ "id": z.coerce.number().int(), "name": z.coerce.string(), "date": z.coerce.date().optional(), "tag": z.coerce.string().min(5).max(100).optional() });
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+
3
+ export const pet = z.object({ "id": z.number().int(), "name": z.string(), "date": z.coerce.date().optional(), "tag": z.string().min(5).max(100).optional() });
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+
3
+ export const pet = z.object({ "id": z.coerce.number().int(), "name": z.string(), "date": z.date().optional(), "tag": z.string().min(5).max(100).optional() });
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+
3
+ export const pet = z.object({ "id": z.number().int(), "name": z.coerce.string(), "date": z.date().optional(), "tag": z.coerce.string().min(5).max(100).optional() });
@@ -0,0 +1,15 @@
1
+ import { z } from "zod";
2
+
3
+ /**
4
+ * @description Null response
5
+ */
6
+ export const createPets201 = z.any();
7
+
8
+ /**
9
+ * @description unexpected error
10
+ */
11
+ export const createPetsError = z.lazy(() => error);
12
+
13
+ export const createPetsMutationRequest = z.object({ "name": z.string(), "tag": z.string() });
14
+
15
+ export const createPetsMutationResponse = z.lazy(() => createPets201);
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @description Null response
3
+ */
4
+ export const createPetWithUnknownTypeAny = z.any()
5
+
6
+ /**
7
+ * @description unexpected error
8
+ */
9
+ export const createPetWithUnknownTypeAny = z.lazy(() => createPetWithUnknownTypeAny)
10
+
11
+ export const createPetWithUnknownTypeAny = z.object({ name: z.string(), tag: z.string() })
12
+
13
+ export const createPetWithUnknownTypeAny = z.any()
@@ -0,0 +1,15 @@
1
+ import { z } from "zod";
2
+
3
+ /**
4
+ * @description Null response
5
+ */
6
+ export const createPets201 = z.unknown();
7
+
8
+ /**
9
+ * @description unexpected error
10
+ */
11
+ export const createPetsError = z.lazy(() => error);
12
+
13
+ export const createPetsMutationRequest = z.object({ "name": z.string(), "tag": z.string() });
14
+
15
+ export const createPetsMutationResponse = z.lazy(() => createPets201);
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+
3
+ export const deletePetsPetidMutationResponse = z.any();
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+
3
+ export const advanced = z.union([z.lazy(() => enumerationValueSpecificationDto).and(z.object({ "type": z.enum(["enum", "range", "regex", "slider"]) })), z.lazy(() => rangeValueSpecificationDto).and(z.object({ "type": z.enum(["enum", "range", "regex", "slider"]) })), z.lazy(() => regexValueSpecificationDto).and(z.object({ "type": z.enum(["enum", "range", "regex", "slider"]) })), z.lazy(() => sliderValueSpecificationDto).and(z.object({ "type": z.enum(["enum", "range", "regex", "slider"]) }))]);
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+
3
+ export const enumBooleanLiteral = z.union([z.literal(true), z.literal(false)]);
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+
3
+ export const enumNamesType = z.enum(["0", "1"]);
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+
3
+ export const enumNullable = z.enum(["Pending", "Received"]).nullable();
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+
3
+ export const enumSingleLiteral = z.literal(0);
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+
3
+ export const enumVarNamesType = z.union([z.literal(0), z.literal(1)]);
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+
3
+ export const example = z.object({ "nestedExamples": z.lazy(() => example).optional() });
@@ -0,0 +1,15 @@
1
+ import { z } from "zod";
2
+
3
+ export const listPetsQueryParams = z.object({ "limit": z.string().describe("How many items to return at one time (max 100)").optional(), "offset": z.number().int().default(0) }).optional();
4
+
5
+ /**
6
+ * @description A paged array of pets
7
+ */
8
+ export const listPets200 = z.lazy(() => pets);
9
+
10
+ /**
11
+ * @description unexpected error
12
+ */
13
+ export const listPetsError = z.lazy(() => error);
14
+
15
+ export const listPetsQueryResponse = z.lazy(() => listPets200);
@@ -0,0 +1,6 @@
1
+ import { z } from "zod";
2
+
3
+ /**
4
+ * @description This probably should fail miserably
5
+ */
6
+ export const mixedValueTypeConst = z.object({ "foobar": z.literal("foobar") }).describe("This probably should fail miserably");
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+
3
+ export const nullableString = z.string().nullable();
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+
3
+ export const nullableStringUuid = z.string().uuid().nullable();
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+
3
+ export const nullableStringWithAnyOf = z.union([z.string(), z.null()]);
@@ -0,0 +1,6 @@
1
+ import { z } from "zod";
2
+
3
+ /**
4
+ * @description its value is equal to the value of the keyword
5
+ */
6
+ export const numberValueConst = z.object({ "foobar": z.literal(42) }).describe("its value is equal to the value of the keyword");
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+
3
+ export const test = z.union([z.object({ "propertyA": z.string().optional() }), z.object({ "propertyA": z.string().optional() })]);
@@ -0,0 +1,43 @@
1
+ import { listPetsQueryResponse, listPetsQueryParams, createPetsMutationRequest, createPetsMutationResponse, showPetByIdQueryResponse, showPetByIdPathParams } from "./showPetById";
2
+
3
+ export const operations = { "listPets": {
4
+ request: undefined,
5
+ parameters: {
6
+ path: undefined,
7
+ query: listPetsQueryParams,
8
+ header: undefined
9
+ },
10
+ responses: {
11
+ default: listPetsQueryResponse
12
+ },
13
+ errors: {}
14
+ }, "createPets": {
15
+ request: createPetsMutationRequest,
16
+ parameters: {
17
+ path: undefined,
18
+ query: undefined,
19
+ header: undefined
20
+ },
21
+ responses: {
22
+ default: createPetsMutationResponse
23
+ },
24
+ errors: {}
25
+ }, "showPetById": {
26
+ request: undefined,
27
+ parameters: {
28
+ path: showPetByIdPathParams,
29
+ query: undefined,
30
+ header: undefined
31
+ },
32
+ responses: {
33
+ default: showPetByIdQueryResponse
34
+ },
35
+ errors: {}
36
+ } } as const;
37
+
38
+ export const paths = { "/pets": {
39
+ get: operations["listPets"],
40
+ post: operations["createPets"]
41
+ }, "/pets/{petId}": {
42
+ get: operations["showPetById"]
43
+ } } as const;
@@ -0,0 +1,5 @@
1
+ import { z } from "zod";
2
+
3
+ export const optionalPet = z.object({ "id": z.number().int().optional(), "name": z.string().optional(), "tag": z.string().optional() });
4
+
5
+ export type OptionalPet = z.infer<typeof optionalPet>;
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+
3
+ export const optionalPet = z.object({ "id": z.number().int().optional(), "name": z.string().optional(), "tag": z.string().optional() }) as z.ZodType<OptionalPet>;
@@ -0,0 +1,3 @@
1
+ import { z } from "zod";
2
+
3
+ export const order = z.object({ "id": z.number().int().optional(), "petId": z.number().int().optional(), "quantity": z.number().int().optional(), "shipDate": z.date().optional(), "status": z.enum(["placed", "approved", "delivered"]).describe("Order Status").optional(), "complete": z.boolean().optional() });
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod'
2
+
3
+ export const order = z.object({
4
+ id: z.number().int().optional(),
5
+ petId: z.number().int().optional(),
6
+ quantity: z.number().int().optional(),
7
+ shipDate: z.string().datetime().optional(),
8
+ status: z.enum(['placed', 'approved', 'delivered']).describe('Order Status').optional(),
9
+ complete: z.boolean().optional(),
10
+ })