@kubb/plugin-zod 0.0.0-canary-20251103132818 → 0.0.0-canary-20251103161135
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.
- package/dist/{components-DpM7dEpH.js → components-BtBB23cQ.js} +82 -72
- package/dist/components-BtBB23cQ.js.map +1 -0
- package/dist/{components-BiOh-7_I.cjs → components-DIUzzW4k.cjs} +82 -72
- package/dist/components-DIUzzW4k.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +3 -3
- package/dist/components.d.ts +3 -3
- package/dist/components.js +1 -1
- package/dist/{generators-pT2oV1kT.js → generators-9upbJt-4.js} +4 -4
- package/dist/generators-9upbJt-4.js.map +1 -0
- package/dist/{generators-DXfU6W14.cjs → generators-T3e_E7Uy.cjs} +4 -4
- package/dist/generators-T3e_E7Uy.cjs.map +1 -0
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{types-Dz_P13wd.d.ts → types-CQSK_Scm.d.cts} +2 -5
- package/dist/{types-DBZGvY3G.d.cts → types-DcQBOr_-.d.ts} +2 -5
- package/package.json +6 -6
- package/src/components/Zod.tsx +7 -13
- package/src/generators/__snapshots__/createPet.ts +2 -2
- package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown.ts +2 -2
- package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown_wrapOutput.ts +7 -9
- package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown_wrapOutput_entire_.ts +7 -10
- package/src/generators/__snapshots__/createPet_wrapOutput.ts +7 -9
- package/src/generators/__snapshots__/discriminator.ts +20 -28
- package/src/generators/__snapshots__/getPets.ts +3 -3
- package/src/generators/__snapshots__/getPets_wrapOutput.ts +8 -10
- package/src/generators/__snapshots__/petArray.ts +1 -5
- package/src/generators/__snapshots__/queryAllDefaulted.ts +1 -1
- package/src/generators/__snapshots__/queryAllDefaulted_wrapOutput.ts +2 -2
- package/src/generators/__snapshots__/showPetById.ts +3 -3
- package/src/generators/__snapshots__/showPetById_wrapOutput.ts +8 -10
- package/src/generators/zodGenerator.tsx +2 -2
- package/src/parser.ts +37 -36
- package/dist/components-BiOh-7_I.cjs.map +0 -1
- package/dist/components-DpM7dEpH.js.map +0 -1
- package/dist/generators-DXfU6W14.cjs.map +0 -1
- package/dist/generators-pT2oV1kT.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./components-
|
|
2
|
-
import { n as operationsGenerator, t as zodGenerator } from "./generators-
|
|
1
|
+
import "./components-BtBB23cQ.js";
|
|
2
|
+
import { n as operationsGenerator, t as zodGenerator } from "./generators-9upbJt-4.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { PackageManager, PluginManager, createPlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
5
5
|
import { camelCase, pascalCase } from "@kubb/core/transformers";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
2
1
|
import * as OasTypes from "oas/types";
|
|
3
2
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
4
3
|
import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
@@ -6,6 +5,7 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
6
5
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
7
6
|
import BaseOas from "oas";
|
|
8
7
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
8
|
+
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
9
9
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
10
10
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
11
11
|
|
|
@@ -912,10 +912,7 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
|
|
|
912
912
|
* optionally adds a union with null.
|
|
913
913
|
*/
|
|
914
914
|
parse(props: SchemaProps$1): Schema[];
|
|
915
|
-
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
916
|
-
find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
917
915
|
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
918
|
-
static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
919
916
|
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
920
917
|
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
921
918
|
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
@@ -1121,4 +1118,4 @@ type ResolvedOptions = {
|
|
|
1121
1118
|
type PluginZod = PluginFactoryOptions<'plugin-zod', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1122
1119
|
//#endregion
|
|
1123
1120
|
export { UserPluginWithLifeCycle as a, Schema as i, PluginZod as n, Operation$1 as o, ReactGenerator as r, SchemaObject$1 as s, Options$1 as t };
|
|
1124
|
-
//# sourceMappingURL=types-
|
|
1121
|
+
//# sourceMappingURL=types-CQSK_Scm.d.cts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
1
2
|
import * as OasTypes from "oas/types";
|
|
2
3
|
import { HttpMethods as HttpMethod, OASDocument, SchemaObject, User } from "oas/types";
|
|
3
4
|
import { Operation, Operation as Operation$1 } from "oas/operation";
|
|
@@ -5,7 +6,6 @@ import { OpenAPIV3 } from "openapi-types";
|
|
|
5
6
|
import * as oas_normalize_lib_types0 from "oas-normalize/lib/types";
|
|
6
7
|
import BaseOas from "oas";
|
|
7
8
|
import { KubbFile } from "@kubb/fabric-core/types";
|
|
8
|
-
import { Fabric, FileManager } from "@kubb/react-fabric";
|
|
9
9
|
import { ConsolaInstance, LogLevel } from "consola";
|
|
10
10
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
11
11
|
|
|
@@ -912,10 +912,7 @@ declare class SchemaGenerator<TOptions extends SchemaGeneratorOptions = SchemaGe
|
|
|
912
912
|
* optionally adds a union with null.
|
|
913
913
|
*/
|
|
914
914
|
parse(props: SchemaProps$1): Schema[];
|
|
915
|
-
deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
916
|
-
find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
917
915
|
static deepSearch<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): Array<SchemaKeywordMapper[T]>;
|
|
918
|
-
static findInObject<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
919
916
|
static find<T extends keyof SchemaKeywordMapper>(tree: Schema[] | undefined, keyword: T): SchemaKeywordMapper[T] | undefined;
|
|
920
917
|
static combineObjects(tree: Schema[] | undefined): Schema[];
|
|
921
918
|
build(...generators: Array<Generator<TPluginOptions>>): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
@@ -1121,4 +1118,4 @@ type ResolvedOptions = {
|
|
|
1121
1118
|
type PluginZod = PluginFactoryOptions<'plugin-zod', Options$1, ResolvedOptions, never, ResolvePathOptions>;
|
|
1122
1119
|
//#endregion
|
|
1123
1120
|
export { UserPluginWithLifeCycle as a, Schema as i, PluginZod as n, Operation$1 as o, ReactGenerator as r, SchemaObject$1 as s, Options$1 as t };
|
|
1124
|
-
//# sourceMappingURL=types-
|
|
1121
|
+
//# sourceMappingURL=types-DcQBOr_-.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-zod",
|
|
3
|
-
"version": "0.0.0-canary-
|
|
3
|
+
"version": "0.0.0-canary-20251103161135",
|
|
4
4
|
"description": "Zod schema generator plugin for Kubb, creating type-safe validation schemas from OpenAPI specifications for runtime data validation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"zod",
|
|
@@ -69,16 +69,16 @@
|
|
|
69
69
|
],
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@kubb/react-fabric": "0.2.14",
|
|
72
|
-
"@kubb/core": "0.0.0-canary-
|
|
73
|
-
"@kubb/oas": "0.0.0-canary-
|
|
74
|
-
"@kubb/plugin-oas": "0.0.0-canary-
|
|
75
|
-
"@kubb/plugin-ts": "0.0.0-canary-
|
|
72
|
+
"@kubb/core": "0.0.0-canary-20251103161135",
|
|
73
|
+
"@kubb/oas": "0.0.0-canary-20251103161135",
|
|
74
|
+
"@kubb/plugin-oas": "0.0.0-canary-20251103161135",
|
|
75
|
+
"@kubb/plugin-ts": "0.0.0-canary-20251103161135"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@asteasolutions/zod-to-openapi": "^8.1.0",
|
|
79
79
|
"@hono/zod-openapi": "0.19.2",
|
|
80
80
|
"zod": "^3.25.76",
|
|
81
|
-
"@kubb/plugin-oas": "0.0.0-canary-
|
|
81
|
+
"@kubb/plugin-oas": "0.0.0-canary-20251103161135"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
84
|
"@kubb/react-fabric": "0.2.14"
|
package/src/components/Zod.tsx
CHANGED
|
@@ -11,7 +11,7 @@ type Props = {
|
|
|
11
11
|
typeName?: string
|
|
12
12
|
inferTypeName?: string
|
|
13
13
|
tree: Array<Schema>
|
|
14
|
-
|
|
14
|
+
schema: SchemaObject
|
|
15
15
|
description?: string
|
|
16
16
|
coercion: PluginZod['resolvedOptions']['coercion']
|
|
17
17
|
mapper: PluginZod['resolvedOptions']['mapper']
|
|
@@ -25,7 +25,7 @@ export function Zod({
|
|
|
25
25
|
name,
|
|
26
26
|
typeName,
|
|
27
27
|
tree,
|
|
28
|
-
|
|
28
|
+
schema,
|
|
29
29
|
inferTypeName,
|
|
30
30
|
mapper,
|
|
31
31
|
coercion,
|
|
@@ -35,7 +35,7 @@ export function Zod({
|
|
|
35
35
|
version,
|
|
36
36
|
emptySchemaType,
|
|
37
37
|
}: Props): KubbNode {
|
|
38
|
-
const hasTuple = !!SchemaGenerator.
|
|
38
|
+
const hasTuple = !!SchemaGenerator.find(tree, schemaKeywords.tuple)
|
|
39
39
|
|
|
40
40
|
const schemas = parserZod.sort(tree).filter((item) => {
|
|
41
41
|
if (hasTuple && (isKeyword(item, schemaKeywords.min) || isKeyword(item, schemaKeywords.max))) {
|
|
@@ -49,10 +49,7 @@ export function Zod({
|
|
|
49
49
|
.map((schema, index) => {
|
|
50
50
|
const siblings = schemas.filter((_, i) => i !== index)
|
|
51
51
|
|
|
52
|
-
return parserZod.parse(
|
|
53
|
-
{ parent: undefined, current: schema, siblings },
|
|
54
|
-
{ name, keysToOmit, typeName, description, mapper, coercion, wrapOutput, rawSchema, version },
|
|
55
|
-
)
|
|
52
|
+
return parserZod.parse({ schema, parent: undefined, current: schema, siblings, name }, { mapper, coercion, wrapOutput, version })
|
|
56
53
|
})
|
|
57
54
|
.filter(Boolean)
|
|
58
55
|
.join('')
|
|
@@ -71,28 +68,25 @@ export function Zod({
|
|
|
71
68
|
} else {
|
|
72
69
|
suffix = '.unwrap()'
|
|
73
70
|
}
|
|
74
|
-
} else {
|
|
75
|
-
if (firstSchema && isKeyword(firstSchema, schemaKeywords.ref) && version === '3') {
|
|
76
|
-
suffix = '.schema'
|
|
77
|
-
}
|
|
78
71
|
}
|
|
79
72
|
|
|
80
73
|
const emptyValue = parserZod.parse(
|
|
81
74
|
{
|
|
75
|
+
schema,
|
|
82
76
|
parent: undefined,
|
|
83
77
|
current: {
|
|
84
78
|
keyword: schemaKeywords[emptySchemaType],
|
|
85
79
|
},
|
|
86
80
|
siblings: [],
|
|
87
81
|
},
|
|
88
|
-
{
|
|
82
|
+
{ mapper, coercion, wrapOutput, version },
|
|
89
83
|
)
|
|
90
84
|
|
|
91
85
|
const baseSchemaOutput =
|
|
92
86
|
[output, keysToOmit?.length ? `${suffix}.omit({ ${keysToOmit.map((key) => `'${key}': true`).join(',')} })` : undefined].filter(Boolean).join('') ||
|
|
93
87
|
emptyValue ||
|
|
94
88
|
''
|
|
95
|
-
const wrappedSchemaOutput = wrapOutput ? wrapOutput({ output: baseSchemaOutput, schema
|
|
89
|
+
const wrappedSchemaOutput = wrapOutput ? wrapOutput({ output: baseSchemaOutput, schema }) || baseSchemaOutput : baseSchemaOutput
|
|
96
90
|
const finalOutput = typeName ? `${wrappedSchemaOutput} as unknown as ${version === '4' ? 'z.ZodType' : 'ToZod'}<${typeName}>` : wrappedSchemaOutput
|
|
97
91
|
|
|
98
92
|
return (
|
|
@@ -12,11 +12,11 @@ export const createPets201 = z.unknown()
|
|
|
12
12
|
/**
|
|
13
13
|
* @description unexpected error
|
|
14
14
|
*/
|
|
15
|
-
export const createPetsError =
|
|
15
|
+
export const createPetsError = error
|
|
16
16
|
|
|
17
17
|
export const createPetsMutationRequest = z.object({
|
|
18
18
|
name: z.string(),
|
|
19
19
|
tag: z.string(),
|
|
20
20
|
})
|
|
21
21
|
|
|
22
|
-
export const createPetsMutationResponse =
|
|
22
|
+
export const createPetsMutationResponse = createPets201
|
|
@@ -12,11 +12,11 @@ export const createPets201 = z.unknown()
|
|
|
12
12
|
/**
|
|
13
13
|
* @description unexpected error
|
|
14
14
|
*/
|
|
15
|
-
export const createPetsError =
|
|
15
|
+
export const createPetsError = error
|
|
16
16
|
|
|
17
17
|
export const createPetsMutationRequest = z.object({
|
|
18
18
|
name: z.string(),
|
|
19
19
|
tag: z.string(),
|
|
20
20
|
})
|
|
21
21
|
|
|
22
|
-
export const createPetsMutationResponse =
|
|
22
|
+
export const createPetsMutationResponse = createPets201
|
|
@@ -12,18 +12,16 @@ export const createPets201 = z.unknown()
|
|
|
12
12
|
/**
|
|
13
13
|
* @description unexpected error
|
|
14
14
|
*/
|
|
15
|
-
export const createPetsError =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
],
|
|
22
|
-
})
|
|
15
|
+
export const createPetsError = error.openapi({
|
|
16
|
+
examples: [
|
|
17
|
+
{ sample: { summary: 'A sample error', value: { code: 1, message: 'A sample error message' } } },
|
|
18
|
+
{ other_example: { summary: 'Another sample error', value: { code: 2, message: 'A totally specific message' } } },
|
|
19
|
+
],
|
|
20
|
+
})
|
|
23
21
|
|
|
24
22
|
export const createPetsMutationRequest = z.object({
|
|
25
23
|
name: z.string().openapi({ example: 'Baxter' }),
|
|
26
24
|
tag: z.string(),
|
|
27
25
|
})
|
|
28
26
|
|
|
29
|
-
export const createPetsMutationResponse =
|
|
27
|
+
export const createPetsMutationResponse = createPets201
|
|
@@ -12,19 +12,16 @@ export const createPets201 = z.unknown()
|
|
|
12
12
|
/**
|
|
13
13
|
* @description unexpected error
|
|
14
14
|
*/
|
|
15
|
-
export const createPetsError = extendApi(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
],
|
|
22
|
-
},
|
|
23
|
-
)
|
|
15
|
+
export const createPetsError = extendApi(error, {
|
|
16
|
+
examples: [
|
|
17
|
+
{ sample: { summary: 'A sample error', value: { code: 1, message: 'A sample error message' } } },
|
|
18
|
+
{ other_example: { summary: 'Another sample error', value: { code: 2, message: 'A totally specific message' } } },
|
|
19
|
+
],
|
|
20
|
+
})
|
|
24
21
|
|
|
25
22
|
export const createPetsMutationRequest = z.object({
|
|
26
23
|
name: extendApi(z.string(), { example: 'Baxter' }),
|
|
27
24
|
tag: z.string(),
|
|
28
25
|
})
|
|
29
26
|
|
|
30
|
-
export const createPetsMutationResponse =
|
|
27
|
+
export const createPetsMutationResponse = createPets201
|
|
@@ -12,18 +12,16 @@ export const createPets201 = z.unknown()
|
|
|
12
12
|
/**
|
|
13
13
|
* @description unexpected error
|
|
14
14
|
*/
|
|
15
|
-
export const createPetsError =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
],
|
|
22
|
-
})
|
|
15
|
+
export const createPetsError = error.openapi({
|
|
16
|
+
examples: [
|
|
17
|
+
{ sample: { summary: 'A sample error', value: { code: 1, message: 'A sample error message' } } },
|
|
18
|
+
{ other_example: { summary: 'Another sample error', value: { code: 2, message: 'A totally specific message' } } },
|
|
19
|
+
],
|
|
20
|
+
})
|
|
23
21
|
|
|
24
22
|
export const createPetsMutationRequest = z.object({
|
|
25
23
|
name: z.string().openapi({ example: 'Baxter' }),
|
|
26
24
|
tag: z.string(),
|
|
27
25
|
})
|
|
28
26
|
|
|
29
|
-
export const createPetsMutationResponse =
|
|
27
|
+
export const createPetsMutationResponse = createPets201
|
|
@@ -5,32 +5,24 @@
|
|
|
5
5
|
import { z } from 'zod'
|
|
6
6
|
|
|
7
7
|
export const advanced = z.union([
|
|
8
|
-
|
|
9
|
-
.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
.
|
|
25
|
-
z.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
),
|
|
29
|
-
z
|
|
30
|
-
.lazy(() => sliderValueSpecificationDto)
|
|
31
|
-
.and(
|
|
32
|
-
z.object({
|
|
33
|
-
type: z.literal('slider'),
|
|
34
|
-
}),
|
|
35
|
-
),
|
|
8
|
+
enumerationValueSpecificationDto.and(
|
|
9
|
+
z.object({
|
|
10
|
+
type: z.literal('enum'),
|
|
11
|
+
}),
|
|
12
|
+
),
|
|
13
|
+
rangeValueSpecificationDto.and(
|
|
14
|
+
z.object({
|
|
15
|
+
type: z.literal('range'),
|
|
16
|
+
}),
|
|
17
|
+
),
|
|
18
|
+
regexValueSpecificationDto.and(
|
|
19
|
+
z.object({
|
|
20
|
+
type: z.literal('regex'),
|
|
21
|
+
}),
|
|
22
|
+
),
|
|
23
|
+
sliderValueSpecificationDto.and(
|
|
24
|
+
z.object({
|
|
25
|
+
type: z.literal('slider'),
|
|
26
|
+
}),
|
|
27
|
+
),
|
|
36
28
|
])
|
|
@@ -12,11 +12,11 @@ export const listPetsQueryParams = z.object({
|
|
|
12
12
|
/**
|
|
13
13
|
* @description A paged array of pets
|
|
14
14
|
*/
|
|
15
|
-
export const listPets200 =
|
|
15
|
+
export const listPets200 = pets
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @description unexpected error
|
|
19
19
|
*/
|
|
20
|
-
export const listPetsError =
|
|
20
|
+
export const listPetsError = error
|
|
21
21
|
|
|
22
|
-
export const listPetsQueryResponse =
|
|
22
|
+
export const listPetsQueryResponse = listPets200
|
|
@@ -12,18 +12,16 @@ export const listPetsQueryParams = z.object({
|
|
|
12
12
|
/**
|
|
13
13
|
* @description A paged array of pets
|
|
14
14
|
*/
|
|
15
|
-
export const listPets200 =
|
|
15
|
+
export const listPets200 = pets
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @description unexpected error
|
|
19
19
|
*/
|
|
20
|
-
export const listPetsError =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
],
|
|
27
|
-
})
|
|
20
|
+
export const listPetsError = error.openapi({
|
|
21
|
+
examples: [
|
|
22
|
+
{ sample: { summary: 'A sample error', value: { code: 1, message: 'A sample error message' } } },
|
|
23
|
+
{ other_example: { summary: 'Another sample error', value: { code: 2, message: 'A totally specific message' } } },
|
|
24
|
+
],
|
|
25
|
+
})
|
|
28
26
|
|
|
29
|
-
export const listPetsQueryResponse =
|
|
27
|
+
export const listPetsQueryResponse = listPets200
|
|
@@ -7,8 +7,4 @@ import { z } from 'zod'
|
|
|
7
7
|
/**
|
|
8
8
|
* @description List of Pet object
|
|
9
9
|
*/
|
|
10
|
-
export const petArray = z
|
|
11
|
-
.array(z.lazy(() => pet))
|
|
12
|
-
.min(1)
|
|
13
|
-
.max(3)
|
|
14
|
-
.describe('List of Pet object')
|
|
10
|
+
export const petArray = z.array(pet).min(1).max(3).describe('List of Pet object')
|
|
@@ -13,7 +13,7 @@ export const getThingsQueryParams = z.object({
|
|
|
13
13
|
* @description A list of things
|
|
14
14
|
*/
|
|
15
15
|
export const getThings200 = z.object({
|
|
16
|
-
items: z.array(
|
|
16
|
+
items: z.array(thing),
|
|
17
17
|
})
|
|
18
18
|
|
|
19
|
-
export const getThingsQueryResponse =
|
|
19
|
+
export const getThingsQueryResponse = getThings200
|
|
@@ -12,11 +12,11 @@ export const showPetByIdPathParams = z.object({
|
|
|
12
12
|
/**
|
|
13
13
|
* @description Expected response to a valid request
|
|
14
14
|
*/
|
|
15
|
-
export const showPetById200 =
|
|
15
|
+
export const showPetById200 = pet
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @description unexpected error
|
|
19
19
|
*/
|
|
20
|
-
export const showPetByIdError =
|
|
20
|
+
export const showPetByIdError = error
|
|
21
21
|
|
|
22
|
-
export const showPetByIdQueryResponse =
|
|
22
|
+
export const showPetByIdQueryResponse = showPetById200
|
|
@@ -12,18 +12,16 @@ export const showPetByIdPathParams = z.object({
|
|
|
12
12
|
/**
|
|
13
13
|
* @description Expected response to a valid request
|
|
14
14
|
*/
|
|
15
|
-
export const showPetById200 =
|
|
15
|
+
export const showPetById200 = pet
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @description unexpected error
|
|
19
19
|
*/
|
|
20
|
-
export const showPetByIdError =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
],
|
|
27
|
-
})
|
|
20
|
+
export const showPetByIdError = error.openapi({
|
|
21
|
+
examples: [
|
|
22
|
+
{ sample: { summary: 'A sample error', value: { code: 1, message: 'A sample error message' } } },
|
|
23
|
+
{ other_example: { summary: 'Another sample error', value: { code: 2, message: 'A totally specific message' } } },
|
|
24
|
+
],
|
|
25
|
+
})
|
|
28
26
|
|
|
29
|
-
export const showPetByIdQueryResponse =
|
|
27
|
+
export const showPetByIdQueryResponse = showPetById200
|
|
@@ -81,7 +81,7 @@ export const zodGenerator = createReactGenerator<PluginZod>({
|
|
|
81
81
|
inferTypeName={inferred ? zod.inferTypeName : undefined}
|
|
82
82
|
description={description}
|
|
83
83
|
tree={tree}
|
|
84
|
-
|
|
84
|
+
schema={schemaObject}
|
|
85
85
|
mapper={mapper}
|
|
86
86
|
coercion={coercion}
|
|
87
87
|
keysToOmit={keysToOmit}
|
|
@@ -150,7 +150,7 @@ export const zodGenerator = createReactGenerator<PluginZod>({
|
|
|
150
150
|
inferTypeName={inferred ? zod.inferTypeName : undefined}
|
|
151
151
|
description={schema.value.description}
|
|
152
152
|
tree={schema.tree}
|
|
153
|
-
|
|
153
|
+
schema={schema.value}
|
|
154
154
|
mapper={mapper}
|
|
155
155
|
coercion={coercion}
|
|
156
156
|
wrapOutput={wrapOutput}
|