@kubb/plugin-zod 3.0.0-alpha.17 → 3.0.0-alpha.18
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/README.md +0 -4
- package/dist/{chunk-Q7F7N57F.cjs → chunk-G5M2ERLS.cjs} +4 -4
- package/dist/{chunk-Q7F7N57F.cjs.map → chunk-G5M2ERLS.cjs.map} +1 -1
- package/dist/{chunk-35K4FTRK.js → chunk-UPICPEOA.js} +4 -4
- package/dist/{chunk-35K4FTRK.js.map → chunk-UPICPEOA.js.map} +1 -1
- package/dist/{chunk-ORFIAMY6.js → chunk-Y7E62IFJ.js} +3 -3
- package/dist/{chunk-ORFIAMY6.js.map → chunk-Y7E62IFJ.js.map} +1 -1
- package/dist/{chunk-HH7DZZUF.cjs → chunk-ZVLPHBJB.cjs} +26 -26
- package/dist/{chunk-HH7DZZUF.cjs.map → chunk-ZVLPHBJB.cjs.map} +1 -1
- package/dist/components.cjs +3 -3
- package/dist/components.js +1 -1
- package/dist/generators.cjs +4 -4
- package/dist/generators.js +2 -2
- package/dist/index.cjs +5 -5
- package/dist/index.js +2 -2
- package/package.json +10 -15
- package/src/generators/__snapshots__/anyof.ts +2 -2
- package/src/generators/__snapshots__/createPet.ts +7 -7
- package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown.ts +7 -7
- package/src/generators/__snapshots__/deletePet.ts +2 -2
- package/src/generators/__snapshots__/enumNamesType.ts +2 -2
- package/src/generators/__snapshots__/enumNullable.ts +2 -2
- package/src/generators/__snapshots__/enumVarNamesType.ts +2 -2
- package/src/generators/__snapshots__/example.ts +2 -2
- package/src/generators/__snapshots__/getPets.ts +8 -8
- package/src/generators/__snapshots__/mixedValueTypeConst.ts +3 -3
- package/src/generators/__snapshots__/nullableString.ts +2 -2
- package/src/generators/__snapshots__/nullableStringUuid.ts +2 -2
- package/src/generators/__snapshots__/nullableStringWithAnyOf.ts +2 -2
- package/src/generators/__snapshots__/numberValueConst.ts +3 -3
- package/src/generators/__snapshots__/oneof.ts +2 -2
- package/src/generators/__snapshots__/operations.ts +44 -58
- package/src/generators/__snapshots__/optionalPetInfer.ts +3 -3
- package/src/generators/__snapshots__/optionalPetTyped.ts +2 -2
- package/src/generators/__snapshots__/order.ts +2 -9
- package/src/generators/__snapshots__/orderDateTypeFalse.ts +2 -9
- package/src/generators/__snapshots__/orderDateTypeString.ts +2 -9
- package/src/generators/__snapshots__/pet.ts +2 -2
- package/src/generators/__snapshots__/petArray.ts +3 -7
- package/src/generators/__snapshots__/petCoercion.ts +2 -7
- package/src/generators/__snapshots__/petTupleObject.ts +3 -3
- package/src/generators/__snapshots__/petWithMapper.ts +2 -2
- package/src/generators/__snapshots__/pets.ts +2 -2
- package/src/generators/__snapshots__/recursive.ts +2 -2
- package/src/generators/__snapshots__/showPetById.ts +8 -11
- package/src/generators/__snapshots__/stringValueConst.ts +3 -3
- package/src/generators/__snapshots__/uuidSchema.ts +2 -2
- package/src/parser/index.ts +1 -1
- package/src/types.ts +0 -5
package/dist/components.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkG5M2ERLS_cjs = require('./chunk-G5M2ERLS.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "Operations", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkG5M2ERLS_cjs.Operations; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "Zod", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkG5M2ERLS_cjs.Zod; }
|
|
14
14
|
});
|
|
15
15
|
//# sourceMappingURL=components.cjs.map
|
|
16
16
|
//# sourceMappingURL=components.cjs.map
|
package/dist/components.js
CHANGED
package/dist/generators.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkZVLPHBJB_cjs = require('./chunk-ZVLPHBJB.cjs');
|
|
4
|
+
require('./chunk-G5M2ERLS.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "operationsGenerator", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkZVLPHBJB_cjs.operationsGenerator; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "zodGenerator", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkZVLPHBJB_cjs.zodGenerator; }
|
|
15
15
|
});
|
|
16
16
|
//# sourceMappingURL=generators.cjs.map
|
|
17
17
|
//# sourceMappingURL=generators.cjs.map
|
package/dist/generators.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { operationsGenerator, zodGenerator } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { operationsGenerator, zodGenerator } from './chunk-Y7E62IFJ.js';
|
|
2
|
+
import './chunk-UPICPEOA.js';
|
|
3
3
|
//# sourceMappingURL=generators.js.map
|
|
4
4
|
//# sourceMappingURL=generators.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkZVLPHBJB_cjs = require('./chunk-ZVLPHBJB.cjs');
|
|
4
|
+
var chunkG5M2ERLS_cjs = require('./chunk-G5M2ERLS.cjs');
|
|
5
5
|
|
|
6
6
|
// src/index.ts
|
|
7
|
-
|
|
7
|
+
chunkG5M2ERLS_cjs.init_cjs_shims();
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, "pluginZod", {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunkZVLPHBJB_cjs.pluginZod; }
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, "pluginZodName", {
|
|
14
14
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunkZVLPHBJB_cjs.pluginZodName; }
|
|
16
16
|
});
|
|
17
17
|
//# sourceMappingURL=index.cjs.map
|
|
18
18
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { pluginZod, pluginZodName } from './chunk-
|
|
2
|
-
import { init_esm_shims } from './chunk-
|
|
1
|
+
export { pluginZod, pluginZodName } from './chunk-Y7E62IFJ.js';
|
|
2
|
+
import { init_esm_shims } from './chunk-UPICPEOA.js';
|
|
3
3
|
|
|
4
4
|
// src/index.ts
|
|
5
5
|
init_esm_shims();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-zod",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.18",
|
|
4
4
|
"description": "Generator plugin-zod",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -58,25 +58,20 @@
|
|
|
58
58
|
"!/**/__tests__/**"
|
|
59
59
|
],
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@kubb/core": "3.0.0-alpha.
|
|
62
|
-
"@kubb/fs": "3.0.0-alpha.
|
|
63
|
-
"@kubb/oas": "3.0.0-alpha.
|
|
64
|
-
"@kubb/parser-ts": "3.0.0-alpha.
|
|
65
|
-
"@kubb/plugin-oas": "3.0.0-alpha.
|
|
66
|
-
"@kubb/react": "3.0.0-alpha.
|
|
67
|
-
"@kubb/types": "3.0.0-alpha.17"
|
|
61
|
+
"@kubb/core": "3.0.0-alpha.18",
|
|
62
|
+
"@kubb/fs": "3.0.0-alpha.18",
|
|
63
|
+
"@kubb/oas": "3.0.0-alpha.18",
|
|
64
|
+
"@kubb/parser-ts": "3.0.0-alpha.18",
|
|
65
|
+
"@kubb/plugin-oas": "3.0.0-alpha.18",
|
|
66
|
+
"@kubb/react": "3.0.0-alpha.18"
|
|
68
67
|
},
|
|
69
68
|
"devDependencies": {
|
|
70
|
-
"@types/react": "^18.3.5",
|
|
71
|
-
"prettier": "^3.3.3",
|
|
72
|
-
"react": "^18.3.1",
|
|
73
69
|
"tsup": "^8.2.4",
|
|
74
|
-
"@kubb/config-
|
|
75
|
-
"@kubb/config-
|
|
76
|
-
"@kubb/config-tsup": "3.0.0-alpha.17"
|
|
70
|
+
"@kubb/config-ts": "3.0.0-alpha.18",
|
|
71
|
+
"@kubb/config-tsup": "3.0.0-alpha.18"
|
|
77
72
|
},
|
|
78
73
|
"peerDependencies": {
|
|
79
|
-
"@kubb/react": "3.0.0-alpha.
|
|
74
|
+
"@kubb/react": "3.0.0-alpha.18"
|
|
80
75
|
},
|
|
81
76
|
"engines": {
|
|
82
77
|
"node": ">=20"
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const test = z.union([z.object({ propertyA: z.string() }).strict(), z.object({ propertyA: z.string(), propertyB: z.string() }).strict()])
|
|
3
|
+
export const test = z.union([z.object({ "propertyA": z.string() }).strict(), z.object({ "propertyA": z.string(), "propertyB": z.string() }).strict()]);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
4
|
* @description Null response
|
|
5
5
|
*/
|
|
6
|
-
export const createPets201 = z.any()
|
|
6
|
+
export const createPets201 = z.any();
|
|
7
7
|
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
9
|
* @description unexpected error
|
|
10
10
|
*/
|
|
11
|
-
export const createPetsError = z.lazy(() => error)
|
|
11
|
+
export const createPetsError = z.lazy(() => error);
|
|
12
12
|
|
|
13
|
-
export const createPetsMutationRequest = z.object({ name: z.string(), tag: z.string() })
|
|
13
|
+
export const createPetsMutationRequest = z.object({ "name": z.string(), "tag": z.string() });
|
|
14
14
|
|
|
15
|
-
export const createPetsMutationResponse = z.any()
|
|
15
|
+
export const createPetsMutationResponse = z.any();
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
4
|
* @description Null response
|
|
5
5
|
*/
|
|
6
|
-
export const createPets201 = z.unknown()
|
|
6
|
+
export const createPets201 = z.unknown();
|
|
7
7
|
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
9
|
* @description unexpected error
|
|
10
10
|
*/
|
|
11
|
-
export const createPetsError = z.lazy(() => error)
|
|
11
|
+
export const createPetsError = z.lazy(() => error);
|
|
12
12
|
|
|
13
|
-
export const createPetsMutationRequest = z.object({ name: z.string(), tag: z.string() })
|
|
13
|
+
export const createPetsMutationRequest = z.object({ "name": z.string(), "tag": z.string() });
|
|
14
14
|
|
|
15
|
-
export const createPetsMutationResponse = z.unknown()
|
|
15
|
+
export const createPetsMutationResponse = z.unknown();
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const deletePetsPetidMutationResponse = z.any()
|
|
3
|
+
export const deletePetsPetidMutationResponse = z.any();
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const enumNamesType = z.enum([
|
|
3
|
+
export const enumNamesType = z.enum(["0", "1"]);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const enumNullable = z.enum([
|
|
3
|
+
export const enumNullable = z.enum(["Pending", "Received"]).nullable();
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const enumVarNamesType = z.union([z.literal(0), z.literal(1)])
|
|
3
|
+
export const enumVarNamesType = z.union([z.literal(0), z.literal(1)]);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const example = z.object({ nestedExamples: z.lazy(() => example).optional() })
|
|
3
|
+
export const example = z.object({ "nestedExamples": z.lazy(() => example).optional() });
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const listPetsQueryParams = z.object({ limit: z.string().describe(
|
|
3
|
+
export const listPetsQueryParams = z.object({ "limit": z.string().describe("How many items to return at one time (max 100)").optional() }).optional();
|
|
4
4
|
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
6
|
* @description A paged array of pets
|
|
7
7
|
*/
|
|
8
|
-
export const listPets200 = z.lazy(() => pets)
|
|
8
|
+
export const listPets200 = z.lazy(() => pets);
|
|
9
9
|
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
11
|
* @description unexpected error
|
|
12
12
|
*/
|
|
13
|
-
export const listPetsError = z.lazy(() => error)
|
|
13
|
+
export const listPetsError = z.lazy(() => error);
|
|
14
14
|
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
16
|
* @description A paged array of pets
|
|
17
17
|
*/
|
|
18
|
-
export const listPetsQueryResponse = z.lazy(() => pets)
|
|
18
|
+
export const listPetsQueryResponse = z.lazy(() => pets);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
4
|
* @description This probably should fail miserably
|
|
5
5
|
*/
|
|
6
|
-
export const mixedValueTypeConst = z.object({ foobar: z.literal(
|
|
6
|
+
export const mixedValueTypeConst = z.object({ "foobar": z.literal("foobar") }).describe("This probably should fail miserably");
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const nullableString = z.string().nullable()
|
|
3
|
+
export const nullableString = z.string().nullable();
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const nullableStringUuid = z.string().uuid().nullable()
|
|
3
|
+
export const nullableStringUuid = z.string().uuid().nullable();
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const nullableStringWithAnyOf = z.union([z.string(), z.null()])
|
|
3
|
+
export const nullableStringWithAnyOf = z.union([z.string(), z.null()]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
4
|
* @description its value is equal to the value of the keyword
|
|
5
5
|
*/
|
|
6
|
-
export const numberValueConst = z.object({ foobar: z.literal(42) }).describe(
|
|
6
|
+
export const numberValueConst = z.object({ "foobar": z.literal(42) }).describe("its value is equal to the value of the keyword");
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const test = z.union([z.object({ propertyA: z.string().optional() }), z.object({ propertyA: z.string().optional() })])
|
|
3
|
+
export const test = z.union([z.object({ "propertyA": z.string().optional() }), z.object({ "propertyA": z.string().optional() })]);
|
|
@@ -1,60 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
listPetsQueryResponse,
|
|
3
|
-
listPetsQueryParams,
|
|
4
|
-
createPetsMutationRequest,
|
|
5
|
-
createPetsMutationResponse,
|
|
6
|
-
showPetByIdQueryResponse,
|
|
7
|
-
showPetByIdPathParams,
|
|
8
|
-
} from './showPetById.ts'
|
|
1
|
+
import { listPetsQueryResponse, listPetsQueryParams, createPetsMutationRequest, createPetsMutationResponse, showPetByIdQueryResponse, showPetByIdPathParams } from "./showPetById.ts";
|
|
9
2
|
|
|
10
|
-
export const operations = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
},
|
|
48
|
-
errors: {},
|
|
49
|
-
},
|
|
50
|
-
} as const
|
|
3
|
+
export const operations = { "listPets": {
|
|
4
|
+
request: undefined,
|
|
5
|
+
parameters: {
|
|
6
|
+
path: undefined,
|
|
7
|
+
query: listPetsQueryParams,
|
|
8
|
+
header: undefined
|
|
9
|
+
},
|
|
10
|
+
responses: {
|
|
11
|
+
200: listPetsQueryResponse,
|
|
12
|
+
default: listPetsQueryResponse
|
|
13
|
+
},
|
|
14
|
+
errors: {}
|
|
15
|
+
}, "createPets": {
|
|
16
|
+
request: createPetsMutationRequest,
|
|
17
|
+
parameters: {
|
|
18
|
+
path: undefined,
|
|
19
|
+
query: undefined,
|
|
20
|
+
header: undefined
|
|
21
|
+
},
|
|
22
|
+
responses: {
|
|
23
|
+
201: createPetsMutationResponse,
|
|
24
|
+
default: createPetsMutationResponse
|
|
25
|
+
},
|
|
26
|
+
errors: {}
|
|
27
|
+
}, "showPetById": {
|
|
28
|
+
request: undefined,
|
|
29
|
+
parameters: {
|
|
30
|
+
path: showPetByIdPathParams,
|
|
31
|
+
query: undefined,
|
|
32
|
+
header: undefined
|
|
33
|
+
},
|
|
34
|
+
responses: {
|
|
35
|
+
200: showPetByIdQueryResponse,
|
|
36
|
+
default: showPetByIdQueryResponse
|
|
37
|
+
},
|
|
38
|
+
errors: {}
|
|
39
|
+
} } as const;
|
|
51
40
|
|
|
52
|
-
export const paths = {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
get: operations['showPetById'],
|
|
59
|
-
},
|
|
60
|
-
} as const
|
|
41
|
+
export const paths = { "/pets": {
|
|
42
|
+
get: operations["listPets"],
|
|
43
|
+
post: operations["createPets"]
|
|
44
|
+
}, "/pets/{petId}": {
|
|
45
|
+
get: operations["showPetById"]
|
|
46
|
+
} } as const;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const optionalPet = z.object({ id: z.number().int().optional(), name: z.string().optional(), tag: z.string().optional() })
|
|
3
|
+
export const optionalPet = z.object({ "id": z.number().int().optional(), "name": z.string().optional(), "tag": z.string().optional() });
|
|
4
4
|
|
|
5
|
-
export type OptionalPet = z.infer<typeof optionalPet
|
|
5
|
+
export type OptionalPet = z.infer<typeof optionalPet>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const optionalPet = z.object({ id: z.number().int().optional(), name: z.string().optional(), tag: z.string().optional() }) as z.ZodType<OptionalPet
|
|
3
|
+
export const optionalPet = z.object({ "id": z.number().int().optional(), "name": z.string().optional(), "tag": z.string().optional() }) as z.ZodType<OptionalPet>;
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
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.date().optional(),
|
|
8
|
-
status: z.enum(['placed', 'approved', 'delivered']).describe('Order Status').optional(),
|
|
9
|
-
complete: z.boolean().optional(),
|
|
10
|
-
})
|
|
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() });
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
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().optional(),
|
|
8
|
-
status: z.enum(['placed', 'approved', 'delivered']).describe('Order Status').optional(),
|
|
9
|
-
complete: z.boolean().optional(),
|
|
10
|
-
})
|
|
3
|
+
export const order = z.object({ "id": z.number().int().optional(), "petId": z.number().int().optional(), "quantity": z.number().int().optional(), "shipDate": z.string().optional(), "status": z.enum(["placed", "approved", "delivered"]).describe("Order Status").optional(), "complete": z.boolean().optional() });
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
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
|
-
})
|
|
3
|
+
export const order = z.object({ "id": z.number().int().optional(), "petId": z.number().int().optional(), "quantity": z.number().int().optional(), "shipDate": z.string().datetime().optional(), "status": z.enum(["placed", "approved", "delivered"]).describe("Order Status").optional(), "complete": z.boolean().optional() });
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const pet = z.object({ id: z.number().int(), name: z.string(), date: z.date().optional(), tag: z.string().min(5).max(100).optional() })
|
|
3
|
+
export const pet = z.object({ "id": z.number().int(), "name": z.string(), "date": z.date().optional(), "tag": z.string().min(5).max(100).optional() });
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
4
|
* @description List of Pet object
|
|
5
5
|
*/
|
|
6
|
-
export const petArray = z
|
|
7
|
-
.array(z.lazy(() => pet))
|
|
8
|
-
.min(1)
|
|
9
|
-
.max(3)
|
|
10
|
-
.describe('List of Pet object')
|
|
6
|
+
export const petArray = z.array(z.lazy(() => pet)).min(1).max(3).describe("List of Pet object");
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const pet = z.object({
|
|
4
|
-
id: z.coerce.number().int(),
|
|
5
|
-
name: z.coerce.string(),
|
|
6
|
-
date: z.coerce.date().optional(),
|
|
7
|
-
tag: z.coerce.string().min(5).max(100).optional(),
|
|
8
|
-
})
|
|
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() });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
4
|
* @description Tuple of exact length 2 nested in an object
|
|
5
5
|
*/
|
|
6
|
-
export const petTupleObject = z.object({ tupleProperty: z.tuple([z.string(), z.string()]).optional() }).describe(
|
|
6
|
+
export const petTupleObject = z.object({ "tupleProperty": z.tuple([z.string(), z.string()]).optional() }).describe("Tuple of exact length 2 nested in an object");
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const pet = z.object({ id: z.number().int(), name: z.string().email(), date: z.date().optional(), tag: z.string().min(5).max(100).optional() })
|
|
3
|
+
export const pet = z.object({ "id": z.number().int(), "name": z.string().email(), "date": z.date().optional(), "tag": z.string().min(5).max(100).optional() });
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const pets = z.array(z.object({ id: z.number().int(), name: z.string(), tag: z.string().optional() })) as z.ZodType<Pets
|
|
3
|
+
export const pets = z.array(z.object({ "id": z.number().int(), "name": z.string(), "tag": z.string().optional() })) as z.ZodType<Pets>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const example = z.object({ name: z.string(), children: z.array(z.lazy(() => example)) })
|
|
3
|
+
export const example = z.object({ "name": z.string(), "children": z.array(z.lazy(() => example)) });
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const showPetByIdPathParams = z.object({
|
|
4
|
-
petId: z.string().describe('The id of the pet to retrieve'),
|
|
5
|
-
testId: z.string().describe('The id of the pet to retrieve'),
|
|
6
|
-
})
|
|
3
|
+
export const showPetByIdPathParams = z.object({ "petId": z.string().describe("The id of the pet to retrieve"), "testId": z.string().describe("The id of the pet to retrieve") });
|
|
7
4
|
|
|
8
|
-
/**
|
|
5
|
+
/**
|
|
9
6
|
* @description Expected response to a valid request
|
|
10
7
|
*/
|
|
11
|
-
export const showPetById200 = z.lazy(() => pet)
|
|
8
|
+
export const showPetById200 = z.lazy(() => pet);
|
|
12
9
|
|
|
13
|
-
/**
|
|
10
|
+
/**
|
|
14
11
|
* @description unexpected error
|
|
15
12
|
*/
|
|
16
|
-
export const showPetByIdError = z.lazy(() => error)
|
|
13
|
+
export const showPetByIdError = z.lazy(() => error);
|
|
17
14
|
|
|
18
|
-
/**
|
|
15
|
+
/**
|
|
19
16
|
* @description Expected response to a valid request
|
|
20
17
|
*/
|
|
21
|
-
export const showPetByIdQueryResponse = z.lazy(() => pet)
|
|
18
|
+
export const showPetByIdQueryResponse = z.lazy(() => pet);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
4
|
* @description its value is equal to the value of the keyword
|
|
5
5
|
*/
|
|
6
|
-
export const stringValueConst = z.object({ foobar: z.literal(
|
|
6
|
+
export const stringValueConst = z.object({ "foobar": z.literal("foobar") }).describe("its value is equal to the value of the keyword");
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const uuidSchema = z.string().uuid()
|
|
3
|
+
export const uuidSchema = z.string().uuid();
|
package/src/parser/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { type SchemaKeywordMapper, isKeyword, schemaKeywords } from '@kubb/plugi
|
|
|
3
3
|
|
|
4
4
|
import type { Schema, SchemaKeywordBase, SchemaMapper } from '@kubb/plugin-oas'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const zodKeywordMapper = {
|
|
7
7
|
any: () => 'z.any()',
|
|
8
8
|
unknown: () => 'z.unknown()',
|
|
9
9
|
number: (coercion?: boolean, min?: number, max?: number) => {
|
package/src/types.ts
CHANGED
|
@@ -128,9 +128,4 @@ type ResolvedOptions = {
|
|
|
128
128
|
operations: NonNullable<Options['coercion']>
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
export type FileMeta = {
|
|
132
|
-
pluginKey?: Plugin['key']
|
|
133
|
-
tag?: string
|
|
134
|
-
}
|
|
135
|
-
|
|
136
131
|
export type PluginZod = PluginFactoryOptions<'plugin-zod', Options, ResolvedOptions, never, ResolvePathOptions>
|