@kubb/plugin-zod 3.1.0 → 3.3.0
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/{chunk-D2WPMTC7.cjs → chunk-27WWRYZI.cjs} +9 -5
- package/dist/chunk-27WWRYZI.cjs.map +1 -0
- package/dist/{chunk-YMVA7BZZ.js → chunk-5NJLJUON.js} +3 -3
- package/dist/{chunk-YMVA7BZZ.js.map → chunk-5NJLJUON.js.map} +1 -1
- package/dist/{chunk-NOXYTLKS.cjs → chunk-B5GU7DW3.cjs} +6 -6
- package/dist/{chunk-NOXYTLKS.cjs.map → chunk-B5GU7DW3.cjs.map} +1 -1
- package/dist/{chunk-SGDZKF6Z.js → chunk-QAVLGGME.js} +9 -5
- package/dist/chunk-QAVLGGME.js.map +1 -0
- 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 +4 -4
- package/dist/index.js +2 -2
- package/package.json +10 -10
- package/src/generators/__snapshots__/anyof.ts +14 -2
- package/src/generators/__snapshots__/coercion.ts +13 -2
- package/src/generators/__snapshots__/coercionDates.ts +13 -2
- package/src/generators/__snapshots__/coercionNumbers.ts +13 -2
- package/src/generators/__snapshots__/coercionStrings.ts +13 -2
- package/src/generators/__snapshots__/createPet.ts +10 -7
- package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown.ts +10 -7
- package/src/generators/__snapshots__/deletePet.ts +2 -2
- package/src/generators/__snapshots__/discriminator.ts +31 -2
- package/src/generators/__snapshots__/enumBooleanLiteral.ts +2 -2
- package/src/generators/__snapshots__/enumNamesType.ts +2 -2
- package/src/generators/__snapshots__/enumNullable.ts +2 -2
- package/src/generators/__snapshots__/enumSingleLiteral.ts +2 -2
- package/src/generators/__snapshots__/enumVarNamesType.ts +2 -2
- package/src/generators/__snapshots__/example.ts +4 -2
- package/src/generators/__snapshots__/getPets.ts +12 -7
- package/src/generators/__snapshots__/mixedValueTypeConst.ts +7 -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 +7 -3
- package/src/generators/__snapshots__/oneof.ts +9 -2
- package/src/generators/__snapshots__/operations.ts +61 -44
- package/src/generators/__snapshots__/optionalPetInfer.ts +7 -3
- package/src/generators/__snapshots__/optionalPetTyped.ts +6 -2
- package/src/generators/__snapshots__/order.ts +9 -2
- package/src/generators/__snapshots__/orderDateTypeFalse.ts +9 -2
- package/src/generators/__snapshots__/orderDateTypeString.ts +9 -2
- package/src/generators/__snapshots__/pet.ts +13 -2
- package/src/generators/__snapshots__/petArray.ts +7 -3
- package/src/generators/__snapshots__/petCoercion.ts +13 -2
- package/src/generators/__snapshots__/petTupleObject.ts +7 -3
- package/src/generators/__snapshots__/petWithMapper.ts +13 -2
- package/src/generators/__snapshots__/pets.ts +8 -2
- package/src/generators/__snapshots__/recursive.ts +5 -2
- package/src/generators/__snapshots__/showPetById.ts +10 -7
- package/src/generators/__snapshots__/stringValueConst.ts +7 -3
- package/src/generators/__snapshots__/toy.ts +8 -2
- package/src/generators/__snapshots__/uuidSchema.ts +2 -2
- package/src/parser/index.ts +7 -3
- package/dist/chunk-D2WPMTC7.cjs.map +0 -1
- package/dist/chunk-SGDZKF6Z.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-zod",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Generator plugin-zod",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -58,18 +58,18 @@
|
|
|
58
58
|
"!/**/__tests__/**"
|
|
59
59
|
],
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@kubb/core": "3.
|
|
62
|
-
"@kubb/fs": "3.
|
|
63
|
-
"@kubb/oas": "3.
|
|
64
|
-
"@kubb/parser-ts": "3.
|
|
65
|
-
"@kubb/plugin-oas": "3.
|
|
66
|
-
"@kubb/plugin-ts": "3.
|
|
67
|
-
"@kubb/react": "3.
|
|
61
|
+
"@kubb/core": "3.3.0",
|
|
62
|
+
"@kubb/fs": "3.3.0",
|
|
63
|
+
"@kubb/oas": "3.3.0",
|
|
64
|
+
"@kubb/parser-ts": "3.3.0",
|
|
65
|
+
"@kubb/plugin-oas": "3.3.0",
|
|
66
|
+
"@kubb/plugin-ts": "3.3.0",
|
|
67
|
+
"@kubb/react": "3.3.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"tsup": "^8.3.5",
|
|
71
|
-
"@kubb/config-ts": "3.
|
|
72
|
-
"@kubb/config-tsup": "3.
|
|
71
|
+
"@kubb/config-ts": "3.3.0",
|
|
72
|
+
"@kubb/config-tsup": "3.3.0"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"@kubb/react": "^3.0.0"
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const test = z.union([
|
|
4
|
+
z
|
|
5
|
+
.object({
|
|
6
|
+
propertyA: z.string(),
|
|
7
|
+
})
|
|
8
|
+
.strict(),
|
|
9
|
+
z
|
|
10
|
+
.object({
|
|
11
|
+
propertyA: z.string(),
|
|
12
|
+
propertyB: z.string(),
|
|
13
|
+
})
|
|
14
|
+
.strict(),
|
|
15
|
+
])
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const pet = z.object({
|
|
4
|
+
id: z.coerce.number().int(),
|
|
5
|
+
name: z.coerce.string(),
|
|
6
|
+
date: z.coerce.date().optional(),
|
|
7
|
+
uuid: z.coerce.string().uuid().optional(),
|
|
8
|
+
email: z.coerce.string().email().optional(),
|
|
9
|
+
pattern: z.coerce
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^[a-zA-Z0-9]{3}$/)
|
|
12
|
+
.optional(),
|
|
13
|
+
tag: z.coerce.string().min(5).max(100).optional(),
|
|
14
|
+
})
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const pet = z.object({
|
|
4
|
+
id: z.number().int(),
|
|
5
|
+
name: z.string(),
|
|
6
|
+
date: z.coerce.date().optional(),
|
|
7
|
+
uuid: z.string().uuid().optional(),
|
|
8
|
+
email: z.string().email().optional(),
|
|
9
|
+
pattern: z
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^[a-zA-Z0-9]{3}$/)
|
|
12
|
+
.optional(),
|
|
13
|
+
tag: z.string().min(5).max(100).optional(),
|
|
14
|
+
})
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const pet = z.object({
|
|
4
|
+
id: z.coerce.number().int(),
|
|
5
|
+
name: z.string(),
|
|
6
|
+
date: z.date().optional(),
|
|
7
|
+
uuid: z.string().uuid().optional(),
|
|
8
|
+
email: z.string().email().optional(),
|
|
9
|
+
pattern: z
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^[a-zA-Z0-9]{3}$/)
|
|
12
|
+
.optional(),
|
|
13
|
+
tag: z.string().min(5).max(100).optional(),
|
|
14
|
+
})
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const pet = z.object({
|
|
4
|
+
id: z.number().int(),
|
|
5
|
+
name: z.coerce.string(),
|
|
6
|
+
date: z.date().optional(),
|
|
7
|
+
uuid: z.coerce.string().uuid().optional(),
|
|
8
|
+
email: z.coerce.string().email().optional(),
|
|
9
|
+
pattern: z.coerce
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^[a-zA-Z0-9]{3}$/)
|
|
12
|
+
.optional(),
|
|
13
|
+
tag: z.coerce.string().min(5).max(100).optional(),
|
|
14
|
+
})
|
|
@@ -1,15 +1,18 @@
|
|
|
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
|
-
|
|
13
|
+
export const createPetsMutationRequest = z.object({
|
|
14
|
+
name: z.string(),
|
|
15
|
+
tag: z.string(),
|
|
16
|
+
})
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
export const createPetsMutationResponse = z.lazy(() => createPets201)
|
|
@@ -1,15 +1,18 @@
|
|
|
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
|
-
|
|
13
|
+
export const createPetsMutationRequest = z.object({
|
|
14
|
+
name: z.string(),
|
|
15
|
+
tag: z.string(),
|
|
16
|
+
})
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
export const createPetsMutationResponse = z.lazy(() => createPets201)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const deletePetsPetidMutationResponse = z.any()
|
|
@@ -1,3 +1,32 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const advanced = z.union([
|
|
4
|
+
z
|
|
5
|
+
.lazy(() => enumerationValueSpecificationDto)
|
|
6
|
+
.and(
|
|
7
|
+
z.object({
|
|
8
|
+
type: z.enum(['enum', 'range', 'regex', 'slider']),
|
|
9
|
+
}),
|
|
10
|
+
),
|
|
11
|
+
z
|
|
12
|
+
.lazy(() => rangeValueSpecificationDto)
|
|
13
|
+
.and(
|
|
14
|
+
z.object({
|
|
15
|
+
type: z.enum(['enum', 'range', 'regex', 'slider']),
|
|
16
|
+
}),
|
|
17
|
+
),
|
|
18
|
+
z
|
|
19
|
+
.lazy(() => regexValueSpecificationDto)
|
|
20
|
+
.and(
|
|
21
|
+
z.object({
|
|
22
|
+
type: z.enum(['enum', 'range', 'regex', 'slider']),
|
|
23
|
+
}),
|
|
24
|
+
),
|
|
25
|
+
z
|
|
26
|
+
.lazy(() => sliderValueSpecificationDto)
|
|
27
|
+
.and(
|
|
28
|
+
z.object({
|
|
29
|
+
type: z.enum(['enum', 'range', 'regex', 'slider']),
|
|
30
|
+
}),
|
|
31
|
+
),
|
|
32
|
+
])
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const enumBooleanLiteral = z.union([z.literal(true), z.literal(false)])
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const enumNamesType = z.enum(['0', '1'])
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
3
|
+
export const enumSingleLiteral = z.literal(0)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const enumVarNamesType = z.union([z.literal(0), z.literal(1)])
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const listPetsQueryParams = z
|
|
4
|
+
.object({
|
|
5
|
+
limit: z.string().describe('How many items to return at one time (max 100)').optional(),
|
|
6
|
+
offset: z.number().int().default(0),
|
|
7
|
+
})
|
|
8
|
+
.optional()
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
/**
|
|
6
11
|
* @description A paged array of pets
|
|
7
12
|
*/
|
|
8
|
-
export const listPets200 = z.lazy(() => pets)
|
|
13
|
+
export const listPets200 = z.lazy(() => pets)
|
|
9
14
|
|
|
10
|
-
|
|
15
|
+
/**
|
|
11
16
|
* @description unexpected error
|
|
12
17
|
*/
|
|
13
|
-
export const listPetsError = z.lazy(() => error)
|
|
18
|
+
export const listPetsError = z.lazy(() => error)
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
export const listPetsQueryResponse = z.lazy(() => listPets200)
|
|
@@ -1,6 +1,10 @@
|
|
|
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
|
|
6
|
+
export const mixedValueTypeConst = z
|
|
7
|
+
.object({
|
|
8
|
+
foobar: z.literal('foobar'),
|
|
9
|
+
})
|
|
10
|
+
.describe('This probably should fail miserably')
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const nullableString = z.string().nullable()
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const nullableStringUuid = z.string().uuid().nullable()
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const nullableStringWithAnyOf = z.union([z.string(), z.null()])
|
|
@@ -1,6 +1,10 @@
|
|
|
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
|
|
6
|
+
export const numberValueConst = z
|
|
7
|
+
.object({
|
|
8
|
+
foobar: z.literal(42),
|
|
9
|
+
})
|
|
10
|
+
.describe('its value is equal to the value of the keyword')
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const test = z.union([
|
|
4
|
+
z.object({
|
|
5
|
+
propertyA: z.string().optional(),
|
|
6
|
+
}),
|
|
7
|
+
z.object({
|
|
8
|
+
propertyA: z.string().optional(),
|
|
9
|
+
}),
|
|
10
|
+
])
|
|
@@ -1,46 +1,63 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
listPets200,
|
|
3
|
+
listPetsQueryResponse,
|
|
4
|
+
listPetsQueryParams,
|
|
5
|
+
createPetsMutationRequest,
|
|
6
|
+
createPets201,
|
|
7
|
+
createPetsMutationResponse,
|
|
8
|
+
showPetById200,
|
|
9
|
+
showPetByIdQueryResponse,
|
|
10
|
+
showPetByIdPathParams,
|
|
11
|
+
} from './showPetById'
|
|
2
12
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
13
|
+
export const operations = {
|
|
14
|
+
listPets: {
|
|
15
|
+
request: undefined,
|
|
16
|
+
parameters: {
|
|
17
|
+
path: undefined,
|
|
18
|
+
query: listPetsQueryParams,
|
|
19
|
+
header: undefined,
|
|
20
|
+
},
|
|
21
|
+
responses: {
|
|
22
|
+
200: listPets200,
|
|
23
|
+
default: listPetsQueryResponse,
|
|
24
|
+
},
|
|
25
|
+
errors: {},
|
|
26
|
+
},
|
|
27
|
+
createPets: {
|
|
28
|
+
request: createPetsMutationRequest,
|
|
29
|
+
parameters: {
|
|
30
|
+
path: undefined,
|
|
31
|
+
query: undefined,
|
|
32
|
+
header: undefined,
|
|
33
|
+
},
|
|
34
|
+
responses: {
|
|
35
|
+
201: createPets201,
|
|
36
|
+
default: createPetsMutationResponse,
|
|
37
|
+
},
|
|
38
|
+
errors: {},
|
|
39
|
+
},
|
|
40
|
+
showPetById: {
|
|
41
|
+
request: undefined,
|
|
42
|
+
parameters: {
|
|
43
|
+
path: showPetByIdPathParams,
|
|
44
|
+
query: undefined,
|
|
45
|
+
header: undefined,
|
|
46
|
+
},
|
|
47
|
+
responses: {
|
|
48
|
+
200: showPetById200,
|
|
49
|
+
default: showPetByIdQueryResponse,
|
|
50
|
+
},
|
|
51
|
+
errors: {},
|
|
52
|
+
},
|
|
53
|
+
} as const
|
|
40
54
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
55
|
+
export const paths = {
|
|
56
|
+
'/pets': {
|
|
57
|
+
get: operations['listPets'],
|
|
58
|
+
post: operations['createPets'],
|
|
59
|
+
},
|
|
60
|
+
'/pets/{petId}': {
|
|
61
|
+
get: operations['showPetById'],
|
|
62
|
+
},
|
|
63
|
+
} as const
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const optionalPet = z.object({
|
|
4
|
+
id: z.number().int().optional(),
|
|
5
|
+
name: z.string().optional(),
|
|
6
|
+
tag: z.string().optional(),
|
|
7
|
+
})
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
export type OptionalPet = z.infer<typeof optionalPet>
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const optionalPet = z.object({
|
|
4
|
+
id: z.number().int().optional(),
|
|
5
|
+
name: z.string().optional(),
|
|
6
|
+
tag: z.string().optional(),
|
|
7
|
+
}) as z.ZodType<OptionalPet>
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
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
|
+
})
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
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
|
+
})
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
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
|
+
})
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const pet = z.object({
|
|
4
|
+
id: z.number().int(),
|
|
5
|
+
name: z.string(),
|
|
6
|
+
date: z.date().optional(),
|
|
7
|
+
uuid: z.string().uuid().optional(),
|
|
8
|
+
email: z.string().email().optional(),
|
|
9
|
+
pattern: z
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^[a-zA-Z0-9]{3}$/)
|
|
12
|
+
.optional(),
|
|
13
|
+
tag: z.string().min(5).max(100).optional(),
|
|
14
|
+
})
|
|
@@ -1,6 +1,10 @@
|
|
|
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
|
|
6
|
+
export const petArray = z
|
|
7
|
+
.array(z.lazy(() => pet))
|
|
8
|
+
.min(1)
|
|
9
|
+
.max(3)
|
|
10
|
+
.describe('List of Pet object')
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const pet = z.object({
|
|
4
|
+
id: z.coerce.number().int(),
|
|
5
|
+
name: z.coerce.string(),
|
|
6
|
+
date: z.coerce.date().optional(),
|
|
7
|
+
uuid: z.coerce.string().uuid().optional(),
|
|
8
|
+
email: z.coerce.string().email().optional(),
|
|
9
|
+
pattern: z.coerce
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^[a-zA-Z0-9]{3}$/)
|
|
12
|
+
.optional(),
|
|
13
|
+
tag: z.coerce.string().min(5).max(100).optional(),
|
|
14
|
+
})
|
|
@@ -1,6 +1,10 @@
|
|
|
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
|
|
6
|
+
export const petTupleObject = z
|
|
7
|
+
.object({
|
|
8
|
+
tupleProperty: z.tuple([z.string(), z.string()]).optional(),
|
|
9
|
+
})
|
|
10
|
+
.describe('Tuple of exact length 2 nested in an object')
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const pet = z.object({
|
|
4
|
+
id: z.number().int(),
|
|
5
|
+
name: z.string().email(),
|
|
6
|
+
date: z.date().optional(),
|
|
7
|
+
uuid: z.string().uuid().optional(),
|
|
8
|
+
email: z.string().email().optional(),
|
|
9
|
+
pattern: z
|
|
10
|
+
.string()
|
|
11
|
+
.regex(/^[a-zA-Z0-9]{3}$/)
|
|
12
|
+
.optional(),
|
|
13
|
+
tag: z.string().min(5).max(100).optional(),
|
|
14
|
+
})
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
import { z } from
|
|
1
|
+
import { z } from 'zod'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export const pets = z.array(
|
|
4
|
+
z.object({
|
|
5
|
+
id: z.number().int(),
|
|
6
|
+
name: z.string(),
|
|
7
|
+
tag: z.string().optional(),
|
|
8
|
+
}),
|
|
9
|
+
) as z.ZodType<Pets>
|