@kubb/plugin-zod 4.4.1 → 4.5.1
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-DUJ6Xkpc.js → components-BtBB23cQ.js} +85 -75
- 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-B2hD7k6l.cjs → generators-BOldMlBb.cjs} +119 -123
- package/dist/generators-BOldMlBb.cjs.map +1 -0
- package/dist/{generators-CwEOtNXG.js → generators-DpdxKqO8.js} +120 -125
- package/dist/generators-DpdxKqO8.js.map +1 -0
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +4 -4
- package/dist/generators.d.ts +4 -4
- package/dist/generators.js +2 -2
- package/dist/index.cjs +12 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -2
- package/dist/index.js.map +1 -1
- package/dist/{types-CS916VXJ.d.ts → types-CQSK_Scm.d.cts} +133 -139
- package/dist/{types-Cd7g28dR.d.cts → types-DcQBOr_-.d.ts} +133 -139
- package/package.json +10 -18
- 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 +4 -4
- package/src/generators/__snapshots__/getPets_wrapOutput.ts +8 -10
- package/src/generators/__snapshots__/petArray.ts +1 -5
- package/src/generators/__snapshots__/queryAllDefaulted.ts +3 -3
- 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/index.ts +1 -1
- package/src/generators/operationsGenerator.tsx +5 -5
- package/src/generators/zodGenerator.tsx +35 -25
- package/src/parser.ts +37 -36
- package/src/plugin.ts +15 -0
- package/dist/components-BiOh-7_I.cjs.map +0 -1
- package/dist/components-DUJ6Xkpc.js.map +0 -1
- package/dist/generators-B2hD7k6l.cjs.map +0 -1
- package/dist/generators-CwEOtNXG.js.map +0 -1
- package/dist/utils.cjs +0 -0
- package/dist/utils.d.cts +0 -28
- package/dist/utils.d.ts +0 -28
- package/dist/utils.js +0 -1
- package/src/utils/index.ts +0 -1
- /package/{src/utils → templates}/ToZod.ts +0 -0
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { z } from 'zod'
|
|
6
6
|
|
|
7
7
|
export const getThingsQueryParams = z.object({
|
|
8
|
-
limit: z.
|
|
9
|
-
skip: z.
|
|
8
|
+
limit: z.coerce.number().int().min(1).max(100).default(100).describe('Maximum number of things to return'),
|
|
9
|
+
skip: z.coerce.number().int().min(0).default(0).describe('Number of things to skip'),
|
|
10
10
|
})
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -16,4 +16,4 @@ export const getThings200 = z.object({
|
|
|
16
16
|
items: z.array(z.lazy(() => thing)),
|
|
17
17
|
})
|
|
18
18
|
|
|
19
|
-
export const getThingsQueryResponse =
|
|
19
|
+
export const getThingsQueryResponse = getThings200
|
|
@@ -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
|
package/src/generators/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createReactGenerator } from '@kubb/plugin-oas'
|
|
1
|
+
import { usePluginManager } from '@kubb/core/hooks'
|
|
2
|
+
import { createReactGenerator } from '@kubb/plugin-oas/generators'
|
|
3
3
|
import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
4
4
|
import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
|
|
5
5
|
import { File } from '@kubb/react-fabric'
|
|
@@ -8,15 +8,15 @@ import type { PluginZod } from '../types'
|
|
|
8
8
|
|
|
9
9
|
export const operationsGenerator = createReactGenerator<PluginZod>({
|
|
10
10
|
name: 'operations',
|
|
11
|
-
Operations({ operations }) {
|
|
11
|
+
Operations({ operations, generator, plugin }) {
|
|
12
12
|
const {
|
|
13
13
|
key: pluginKey,
|
|
14
14
|
options: { output, importPath },
|
|
15
|
-
} =
|
|
15
|
+
} = plugin
|
|
16
16
|
const pluginManager = usePluginManager()
|
|
17
17
|
|
|
18
18
|
const oas = useOas()
|
|
19
|
-
const { getFile, groupSchemasByName } = useOperationManager()
|
|
19
|
+
const { getFile, groupSchemasByName } = useOperationManager(generator)
|
|
20
20
|
|
|
21
21
|
const name = 'operations'
|
|
22
22
|
const file = pluginManager.getFile({ name, extname: '.ts', pluginKey })
|
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
import { useMode, usePluginManager } from '@kubb/core/hooks'
|
|
3
|
+
import { type OperationSchema as OperationSchemaType, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'
|
|
4
|
+
import { createReactGenerator } from '@kubb/plugin-oas/generators'
|
|
4
5
|
import { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'
|
|
5
6
|
import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
|
|
6
7
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
7
|
-
import { File } from '@kubb/react-fabric'
|
|
8
|
+
import { File, Fragment } from '@kubb/react-fabric'
|
|
8
9
|
import { Zod } from '../components'
|
|
9
10
|
import type { PluginZod } from '../types'
|
|
10
11
|
|
|
11
12
|
export const zodGenerator = createReactGenerator<PluginZod>({
|
|
12
13
|
name: 'zod',
|
|
13
|
-
Operation({ operation,
|
|
14
|
-
const {
|
|
14
|
+
Operation({ config, operation, generator, plugin }) {
|
|
15
|
+
const {
|
|
16
|
+
options,
|
|
17
|
+
options: { coercion: globalCoercion, inferred, typed, mapper, wrapOutput, version },
|
|
18
|
+
} = plugin
|
|
15
19
|
|
|
16
|
-
const plugin = usePlugin<PluginZod>()
|
|
17
20
|
const mode = useMode()
|
|
18
21
|
const pluginManager = usePluginManager()
|
|
19
22
|
|
|
20
23
|
const oas = useOas()
|
|
21
|
-
const { getSchemas, getFile, getGroup } = useOperationManager()
|
|
24
|
+
const { getSchemas, getFile, getGroup } = useOperationManager(generator)
|
|
22
25
|
const schemaManager = useSchemaManager()
|
|
23
26
|
|
|
24
27
|
const file = getFile(operation)
|
|
25
28
|
const schemas = getSchemas(operation)
|
|
26
29
|
const schemaGenerator = new SchemaGenerator(options, {
|
|
27
|
-
fabric:
|
|
30
|
+
fabric: generator.context.fabric,
|
|
28
31
|
oas,
|
|
29
32
|
plugin,
|
|
30
33
|
pluginManager,
|
|
@@ -36,11 +39,18 @@ export const zodGenerator = createReactGenerator<PluginZod>({
|
|
|
36
39
|
.flat()
|
|
37
40
|
.filter(Boolean)
|
|
38
41
|
|
|
39
|
-
const mapOperationSchema = ({ name, schema: schemaObject, description, keysToOmit, ...options }: OperationSchemaType
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
const
|
|
42
|
+
const mapOperationSchema = ({ name, schema: schemaObject, description, keysToOmit, ...options }: OperationSchemaType) => {
|
|
43
|
+
const hasProperties = Object.keys(schemaObject || {}).length > 0
|
|
44
|
+
const hasDefaults = Object.values(schemaObject.properties || {}).some((prop) => prop && Object.hasOwn(prop, 'default'))
|
|
45
|
+
|
|
46
|
+
const required = Array.isArray(schemaObject?.required) ? schemaObject.required.length > 0 : !!schemaObject?.required
|
|
47
|
+
const optional = !required && !hasDefaults && hasProperties && name.includes('Params')
|
|
48
|
+
|
|
49
|
+
if (!optional && Array.isArray(schemaObject.required) && !schemaObject.required.length) {
|
|
50
|
+
schemaObject.required = Object.entries(schemaObject.properties || {})
|
|
51
|
+
.filter(([_key, value]) => value && Object.hasOwn(value, 'default'))
|
|
52
|
+
.map(([key]) => key)
|
|
53
|
+
}
|
|
44
54
|
|
|
45
55
|
const tree = [...schemaGenerator.parse({ schemaObject, name }), optional ? { keyword: schemaKeywords.optional } : undefined].filter(Boolean)
|
|
46
56
|
const imports = schemaManager.getImports(tree)
|
|
@@ -66,9 +76,9 @@ export const zodGenerator = createReactGenerator<PluginZod>({
|
|
|
66
76
|
}
|
|
67
77
|
|
|
68
78
|
return (
|
|
69
|
-
<
|
|
79
|
+
<Fragment>
|
|
70
80
|
{typed && <File.Import isTypeOnly root={file.path} path={type.file.path} name={[type.name]} />}
|
|
71
|
-
{typed &&
|
|
81
|
+
{typed && version === '3' && <File.Import name={['ToZod']} root={file.path} path={path.resolve(config.root, config.output.path, '.kubb/ToZod.ts')} />}
|
|
72
82
|
{imports.map((imp) => (
|
|
73
83
|
<File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={file.path} path={imp.path} name={imp.name} />
|
|
74
84
|
))}
|
|
@@ -78,7 +88,7 @@ export const zodGenerator = createReactGenerator<PluginZod>({
|
|
|
78
88
|
inferTypeName={inferred ? zod.inferTypeName : undefined}
|
|
79
89
|
description={description}
|
|
80
90
|
tree={tree}
|
|
81
|
-
|
|
91
|
+
schema={schemaObject}
|
|
82
92
|
mapper={mapper}
|
|
83
93
|
coercion={coercion}
|
|
84
94
|
keysToOmit={keysToOmit}
|
|
@@ -86,7 +96,7 @@ export const zodGenerator = createReactGenerator<PluginZod>({
|
|
|
86
96
|
version={plugin.options.version}
|
|
87
97
|
emptySchemaType={plugin.options.emptySchemaType}
|
|
88
98
|
/>
|
|
89
|
-
</
|
|
99
|
+
</Fragment>
|
|
90
100
|
)
|
|
91
101
|
}
|
|
92
102
|
|
|
@@ -103,13 +113,11 @@ export const zodGenerator = createReactGenerator<PluginZod>({
|
|
|
103
113
|
</File>
|
|
104
114
|
)
|
|
105
115
|
},
|
|
106
|
-
Schema({ schema,
|
|
107
|
-
const { coercion, inferred, typed, mapper, importPath, wrapOutput, version } = options
|
|
108
|
-
|
|
116
|
+
Schema({ config, schema, plugin }) {
|
|
109
117
|
const { getName, getFile, getImports } = useSchemaManager()
|
|
110
118
|
const {
|
|
111
|
-
options: { output, emptySchemaType },
|
|
112
|
-
} =
|
|
119
|
+
options: { output, emptySchemaType, coercion, inferred, typed, mapper, importPath, wrapOutput, version },
|
|
120
|
+
} = plugin
|
|
113
121
|
const pluginManager = usePluginManager()
|
|
114
122
|
const oas = useOas()
|
|
115
123
|
|
|
@@ -136,7 +144,9 @@ export const zodGenerator = createReactGenerator<PluginZod>({
|
|
|
136
144
|
>
|
|
137
145
|
<File.Import name={['z']} path={importPath} />
|
|
138
146
|
{typed && <File.Import isTypeOnly root={zod.file.path} path={type.file.path} name={[type.name]} />}
|
|
139
|
-
{typed &&
|
|
147
|
+
{typed && version === '3' && (
|
|
148
|
+
<File.Import name={['ToZod']} root={zod.file.path} path={path.resolve(config.root, config.output.path, '.kubb/ToZod.ts')} />
|
|
149
|
+
)}
|
|
140
150
|
{imports.map((imp) => (
|
|
141
151
|
<File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={zod.file.path} path={imp.path} name={imp.name} />
|
|
142
152
|
))}
|
|
@@ -147,7 +157,7 @@ export const zodGenerator = createReactGenerator<PluginZod>({
|
|
|
147
157
|
inferTypeName={inferred ? zod.inferTypeName : undefined}
|
|
148
158
|
description={schema.value.description}
|
|
149
159
|
tree={schema.tree}
|
|
150
|
-
|
|
160
|
+
schema={schema.value}
|
|
151
161
|
mapper={mapper}
|
|
152
162
|
coercion={coercion}
|
|
153
163
|
wrapOutput={wrapOutput}
|
package/src/parser.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import transformers from '@kubb/core/transformers'
|
|
2
|
-
import type { SchemaObject } from '@kubb/oas'
|
|
3
2
|
|
|
4
3
|
import type { Schema, SchemaKeywordBase, SchemaMapper } from '@kubb/plugin-oas'
|
|
5
4
|
import { isKeyword, SchemaGenerator, type SchemaKeywordMapper, type SchemaTree, schemaKeywords } from '@kubb/plugin-oas'
|
|
@@ -191,12 +190,12 @@ const zodKeywordMapper = {
|
|
|
191
190
|
phone: undefined,
|
|
192
191
|
readOnly: undefined,
|
|
193
192
|
writeOnly: undefined,
|
|
194
|
-
ref: (value?: string,
|
|
193
|
+
ref: (value?: string, lazy = true) => {
|
|
195
194
|
if (!value) {
|
|
196
195
|
return undefined
|
|
197
196
|
}
|
|
198
197
|
|
|
199
|
-
return
|
|
198
|
+
return lazy ? `z.lazy(() => ${value})` : value
|
|
200
199
|
},
|
|
201
200
|
blob: () => 'z.instanceof(File)',
|
|
202
201
|
deprecated: undefined,
|
|
@@ -258,18 +257,14 @@ const shouldCoerce = (coercion: ParserOptions['coercion'] | undefined, type: 'da
|
|
|
258
257
|
}
|
|
259
258
|
|
|
260
259
|
type ParserOptions = {
|
|
261
|
-
|
|
262
|
-
typeName?: string
|
|
263
|
-
description?: string
|
|
264
|
-
keysToOmit?: string[]
|
|
260
|
+
lazy?: boolean
|
|
265
261
|
mapper?: Record<string, string>
|
|
266
262
|
coercion?: boolean | { dates?: boolean; strings?: boolean; numbers?: boolean }
|
|
267
263
|
wrapOutput?: (opts: { output: string; schema: any }) => string | undefined
|
|
268
|
-
rawSchema: SchemaObject
|
|
269
264
|
version: '3' | '4'
|
|
270
265
|
}
|
|
271
266
|
|
|
272
|
-
export function parse({ parent, current, name, siblings }: SchemaTree, options: ParserOptions): string | undefined {
|
|
267
|
+
export function parse({ schema, parent, current, name, siblings }: SchemaTree, options: ParserOptions): string | undefined {
|
|
273
268
|
const value = zodKeywordMapper[current.keyword as keyof typeof zodKeywordMapper]
|
|
274
269
|
|
|
275
270
|
// Early exit: if siblings contain both matches and ref → skip matches entirely
|
|
@@ -287,7 +282,7 @@ export function parse({ parent, current, name, siblings }: SchemaTree, options:
|
|
|
287
282
|
if (isKeyword(current, schemaKeywords.union)) {
|
|
288
283
|
// zod union type needs at least 2 items
|
|
289
284
|
if (Array.isArray(current.args) && current.args.length === 1) {
|
|
290
|
-
return parse({ parent, name
|
|
285
|
+
return parse({ schema, parent, name, current: current.args[0] as Schema, siblings }, options)
|
|
291
286
|
}
|
|
292
287
|
if (Array.isArray(current.args) && !current.args.length) {
|
|
293
288
|
return ''
|
|
@@ -295,7 +290,7 @@ export function parse({ parent, current, name, siblings }: SchemaTree, options:
|
|
|
295
290
|
|
|
296
291
|
return zodKeywordMapper.union(
|
|
297
292
|
sort(current.args)
|
|
298
|
-
.map((
|
|
293
|
+
.map((it, _index, siblings) => parse({ schema, parent: current, name, current: it, siblings }, options))
|
|
299
294
|
.filter(Boolean),
|
|
300
295
|
)
|
|
301
296
|
}
|
|
@@ -305,7 +300,7 @@ export function parse({ parent, current, name, siblings }: SchemaTree, options:
|
|
|
305
300
|
.filter((schema: Schema) => {
|
|
306
301
|
return ![schemaKeywords.optional, schemaKeywords.describe].includes(schema.keyword as typeof schemaKeywords.describe)
|
|
307
302
|
})
|
|
308
|
-
.map((
|
|
303
|
+
.map((it: Schema, _index, siblings) => parse({ schema, parent: current, name, current: it, siblings }, options))
|
|
309
304
|
.filter(Boolean)
|
|
310
305
|
|
|
311
306
|
return `${items.slice(0, 1)}${zodKeywordMapper.and(items.slice(1))}`
|
|
@@ -314,7 +309,9 @@ export function parse({ parent, current, name, siblings }: SchemaTree, options:
|
|
|
314
309
|
if (isKeyword(current, schemaKeywords.array)) {
|
|
315
310
|
return zodKeywordMapper.array(
|
|
316
311
|
sort(current.args.items)
|
|
317
|
-
.map((
|
|
312
|
+
.map((it, _index, siblings) => {
|
|
313
|
+
return parse({ schema, parent: current, name, current: it, siblings }, options)
|
|
314
|
+
})
|
|
318
315
|
.filter(Boolean),
|
|
319
316
|
current.args.min,
|
|
320
317
|
current.args.max,
|
|
@@ -329,7 +326,7 @@ export function parse({ parent, current, name, siblings }: SchemaTree, options:
|
|
|
329
326
|
keyword: schemaKeywords.const,
|
|
330
327
|
args: current.args.items[0],
|
|
331
328
|
}
|
|
332
|
-
return parse({ parent: current, name
|
|
329
|
+
return parse({ schema, parent: current, name, current: child, siblings: [child] }, options)
|
|
333
330
|
}
|
|
334
331
|
|
|
335
332
|
return zodKeywordMapper.union(
|
|
@@ -338,8 +335,8 @@ export function parse({ parent, current, name, siblings }: SchemaTree, options:
|
|
|
338
335
|
keyword: schemaKeywords.const,
|
|
339
336
|
args: schema,
|
|
340
337
|
}))
|
|
341
|
-
.map((
|
|
342
|
-
return parse({ parent: current, name
|
|
338
|
+
.map((it, _index, siblings) => {
|
|
339
|
+
return parse({ schema, parent: current, name, current: it, siblings }, options)
|
|
343
340
|
})
|
|
344
341
|
.filter(Boolean),
|
|
345
342
|
)
|
|
@@ -360,7 +357,7 @@ export function parse({ parent, current, name, siblings }: SchemaTree, options:
|
|
|
360
357
|
}
|
|
361
358
|
|
|
362
359
|
if (isKeyword(current, schemaKeywords.ref)) {
|
|
363
|
-
return zodKeywordMapper.ref(current.args?.name, options.
|
|
360
|
+
return zodKeywordMapper.ref(current.args?.name, options.lazy ?? name === current.args.name)
|
|
364
361
|
}
|
|
365
362
|
|
|
366
363
|
if (isKeyword(current, schemaKeywords.object)) {
|
|
@@ -370,80 +367,84 @@ export function parse({ parent, current, name, siblings }: SchemaTree, options:
|
|
|
370
367
|
})
|
|
371
368
|
|
|
372
369
|
const properties = propertyEntries
|
|
373
|
-
.map(([
|
|
370
|
+
.map(([propertyName, schemas]) => {
|
|
374
371
|
const nameSchema = schemas.find((it) => it.keyword === schemaKeywords.name) as SchemaKeywordMapper['name']
|
|
375
372
|
const isNullable = schemas.some((it) => isKeyword(it, schemaKeywords.nullable))
|
|
376
373
|
const isNullish = schemas.some((it) => isKeyword(it, schemaKeywords.nullish))
|
|
377
374
|
const isOptional = schemas.some((it) => isKeyword(it, schemaKeywords.optional))
|
|
375
|
+
const hasRef = !!SchemaGenerator.find(schemas, schemaKeywords.ref)
|
|
378
376
|
|
|
379
|
-
const mappedName = nameSchema?.args ||
|
|
377
|
+
const mappedName = nameSchema?.args || propertyName
|
|
380
378
|
|
|
381
379
|
// custom mapper(pluginOptions)
|
|
382
380
|
if (options.mapper?.[mappedName]) {
|
|
383
|
-
return `"${
|
|
381
|
+
return `"${propertyName}": ${options.mapper?.[mappedName]}`
|
|
384
382
|
}
|
|
385
383
|
|
|
386
384
|
const baseSchemaOutput = sort(schemas)
|
|
387
385
|
.filter((schema) => {
|
|
388
386
|
return !isKeyword(schema, schemaKeywords.optional) && !isKeyword(schema, schemaKeywords.nullable) && !isKeyword(schema, schemaKeywords.nullish)
|
|
389
387
|
})
|
|
390
|
-
.map((
|
|
388
|
+
.map((it) => {
|
|
389
|
+
const lazy = !(options.version === '4' && hasRef)
|
|
390
|
+
return parse({ schema, parent: current, name, current: it, siblings: schemas }, { ...options, lazy })
|
|
391
|
+
})
|
|
391
392
|
.filter(Boolean)
|
|
392
393
|
.join('')
|
|
393
394
|
|
|
394
395
|
const objectValue = options.wrapOutput
|
|
395
|
-
? options.wrapOutput({ output: baseSchemaOutput, schema:
|
|
396
|
+
? options.wrapOutput({ output: baseSchemaOutput, schema: schema?.properties?.[propertyName] }) || baseSchemaOutput
|
|
396
397
|
: baseSchemaOutput
|
|
397
398
|
|
|
398
|
-
if (options.version === '4' &&
|
|
399
|
+
if (options.version === '4' && hasRef) {
|
|
399
400
|
// both optional and nullable
|
|
400
401
|
if (isNullish) {
|
|
401
|
-
return `get "${
|
|
402
|
-
return ${zodKeywordMapper.nullish(
|
|
402
|
+
return `get "${propertyName}"(){
|
|
403
|
+
return ${objectValue}${zodKeywordMapper.nullish()}
|
|
403
404
|
}`
|
|
404
405
|
}
|
|
405
406
|
|
|
406
407
|
// undefined
|
|
407
408
|
if (isOptional) {
|
|
408
|
-
return `get "${
|
|
409
|
-
return ${zodKeywordMapper.optional(
|
|
409
|
+
return `get "${propertyName}"(){
|
|
410
|
+
return ${objectValue}${zodKeywordMapper.optional()}
|
|
410
411
|
}`
|
|
411
412
|
}
|
|
412
413
|
|
|
413
414
|
// null
|
|
414
415
|
if (isNullable) {
|
|
415
|
-
return `get "${
|
|
416
|
-
|
|
416
|
+
return `get "${propertyName}"(){
|
|
417
|
+
return ${objectValue}${zodKeywordMapper.nullable()}
|
|
417
418
|
}`
|
|
418
419
|
}
|
|
419
420
|
|
|
420
|
-
return `get "${
|
|
421
|
+
return `get "${propertyName}"(){
|
|
421
422
|
return ${objectValue}
|
|
422
423
|
}`
|
|
423
424
|
}
|
|
424
425
|
|
|
425
426
|
// both optional and nullable
|
|
426
427
|
if (isNullish) {
|
|
427
|
-
return `"${
|
|
428
|
+
return `"${propertyName}": ${objectValue}${zodKeywordMapper.nullish()}`
|
|
428
429
|
}
|
|
429
430
|
|
|
430
431
|
// undefined
|
|
431
432
|
if (isOptional) {
|
|
432
|
-
return `"${
|
|
433
|
+
return `"${propertyName}": ${zodKeywordMapper.optional(objectValue)}`
|
|
433
434
|
}
|
|
434
435
|
|
|
435
436
|
// null
|
|
436
437
|
if (isNullable) {
|
|
437
|
-
return `"${
|
|
438
|
+
return `"${propertyName}": ${zodKeywordMapper.nullable(objectValue)}`
|
|
438
439
|
}
|
|
439
440
|
|
|
440
|
-
return `"${
|
|
441
|
+
return `"${propertyName}": ${objectValue}`
|
|
441
442
|
})
|
|
442
443
|
.join(',\n')
|
|
443
444
|
|
|
444
445
|
const additionalProperties = current.args?.additionalProperties?.length
|
|
445
446
|
? current.args.additionalProperties
|
|
446
|
-
.map((
|
|
447
|
+
.map((it, _index, siblings) => parse({ schema, parent: current, name, current: it, siblings }, options))
|
|
447
448
|
.filter(Boolean)
|
|
448
449
|
.join('')
|
|
449
450
|
: undefined
|
|
@@ -458,7 +459,7 @@ export function parse({ parent, current, name, siblings }: SchemaTree, options:
|
|
|
458
459
|
|
|
459
460
|
if (isKeyword(current, schemaKeywords.tuple)) {
|
|
460
461
|
return zodKeywordMapper.tuple(
|
|
461
|
-
current.args.items.map((
|
|
462
|
+
current.args.items.map((it, _index, siblings) => parse({ schema, parent: current, name, current: it, siblings }, options)).filter(Boolean),
|
|
462
463
|
)
|
|
463
464
|
}
|
|
464
465
|
|
package/src/plugin.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
2
|
import { createPlugin, type Group, getBarrelFiles, getMode, PackageManager, type Plugin, PluginManager } from '@kubb/core'
|
|
3
3
|
import { camelCase, pascalCase } from '@kubb/core/transformers'
|
|
4
|
+
import { resolveModuleSource } from '@kubb/core/utils'
|
|
4
5
|
import type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'
|
|
5
6
|
import { OperationGenerator, pluginOasName, SchemaGenerator } from '@kubb/plugin-oas'
|
|
6
7
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
@@ -112,6 +113,20 @@ export const pluginZod = createPlugin<PluginZod>((options) => {
|
|
|
112
113
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
113
114
|
const mode = getMode(path.resolve(root, output.path))
|
|
114
115
|
|
|
116
|
+
if (this.plugin.options.typed && this.plugin.options.version === '3') {
|
|
117
|
+
// pre add bundled fetcher
|
|
118
|
+
await this.addFile({
|
|
119
|
+
baseName: 'ToZod.ts',
|
|
120
|
+
path: path.resolve(root, '.kubb/ToZod.ts'),
|
|
121
|
+
sources: [
|
|
122
|
+
{
|
|
123
|
+
name: 'ToZod',
|
|
124
|
+
value: resolveModuleSource('@kubb/plugin-zod/templates/ToZod').source,
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
|
|
115
130
|
const schemaGenerator = new SchemaGenerator(this.plugin.options, {
|
|
116
131
|
fabric: this.fabric,
|
|
117
132
|
oas,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"components-BiOh-7_I.cjs","names":["File","Type","Const","transformers","order: string[]","schemaKeywords","transformers","name","SchemaGenerator","value","SchemaGenerator","schemaKeywords","parserZod.sort","parserZod.parse","File","Const","transformers","Type"],"sources":["../src/components/Operations.tsx","../src/parser.ts","../src/components/Zod.tsx"],"sourcesContent":["import transformers from '@kubb/core/transformers'\nimport type { HttpMethod, Operation } from '@kubb/oas'\nimport type { SchemaNames } from '@kubb/plugin-oas/hooks'\nimport { Const, File, Type } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\n\ntype Props = {\n name: string\n operations: Array<{ operation: Operation; data: SchemaNames }>\n}\n\nexport function Operations({ name, operations }: Props): KubbNode {\n const operationsJSON = operations.reduce(\n (prev, acc) => {\n prev[`\"${acc.operation.getOperationId()}\"`] = acc.data\n\n return prev\n },\n {} as Record<string, unknown>,\n )\n\n const pathsJSON = operations.reduce(\n (prev, acc) => {\n prev[`\"${acc.operation.path}\"`] = {\n ...(prev[`\"${acc.operation.path}\"`] || ({} as Record<HttpMethod, string>)),\n [acc.operation.method]: `operations[\"${acc.operation.getOperationId()}\"]`,\n }\n\n return prev\n },\n {} as Record<string, Record<HttpMethod, string>>,\n )\n\n return (\n <>\n <File.Source name=\"OperationSchema\" isExportable isIndexable>\n <Type name=\"OperationSchema\" export>{`{\n readonly request: z.ZodTypeAny | undefined;\n readonly parameters: {\n readonly path: z.ZodTypeAny | undefined;\n readonly query: z.ZodTypeAny | undefined;\n readonly header: z.ZodTypeAny | undefined;\n };\n readonly responses: {\n readonly [status: number]: z.ZodTypeAny;\n readonly default: z.ZodTypeAny;\n };\n readonly errors: {\n readonly [status: number]: z.ZodTypeAny;\n };\n}`}</Type>\n </File.Source>\n <File.Source name=\"OperationsMap\" isExportable isIndexable>\n <Type name=\"OperationsMap\" export>\n {'Record<string, OperationSchema>'}\n </Type>\n </File.Source>\n <File.Source name={name} isExportable isIndexable>\n <Const export name={name} asConst>\n {`{${transformers.stringifyObject(operationsJSON)}}`}\n </Const>\n </File.Source>\n <File.Source name={'paths'} isExportable isIndexable>\n <Const export name={'paths'} asConst>\n {`{${transformers.stringifyObject(pathsJSON)}}`}\n </Const>\n </File.Source>\n </>\n )\n}\n","import transformers from '@kubb/core/transformers'\nimport type { SchemaObject } from '@kubb/oas'\n\nimport type { Schema, SchemaKeywordBase, SchemaMapper } from '@kubb/plugin-oas'\nimport { isKeyword, SchemaGenerator, type SchemaKeywordMapper, type SchemaTree, schemaKeywords } from '@kubb/plugin-oas'\n\n//TODO add zodKeywordMapper as function that returns 3 versions: v3, v4 and v4 mini, this can also be used to have the custom mapping(see object type)\n// also include shouldCoerce\n\nconst zodKeywordMapper = {\n any: () => 'z.any()',\n unknown: () => 'z.unknown()',\n void: () => 'z.void()',\n number: (coercion?: boolean, min?: number, max?: number, exclusiveMinimum?: number, exclusiveMaximum?: number) => {\n return [\n coercion ? 'z.coerce.number()' : 'z.number()',\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n exclusiveMinimum !== undefined ? `.gt(${exclusiveMinimum})` : undefined,\n exclusiveMaximum !== undefined ? `.lt(${exclusiveMaximum})` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n integer: (coercion?: boolean, min?: number, max?: number, version: '3' | '4' = '3', exclusiveMinimum?: number, exclusiveMaximum?: number) => {\n return [\n coercion ? 'z.coerce.number().int()' : version === '4' ? 'z.int()' : 'z.number().int()',\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n exclusiveMinimum !== undefined ? `.gt(${exclusiveMinimum})` : undefined,\n exclusiveMaximum !== undefined ? `.lt(${exclusiveMaximum})` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n interface: (value?: string, strict?: boolean) => {\n if (strict) {\n return `z.strictInterface({\n ${value}\n })`\n }\n return `z.interface({\n ${value}\n })`\n },\n object: (value?: string, strict?: boolean, version: '3' | '4' = '3') => {\n if (version === '4' && strict) {\n return `z.strictObject({\n ${value}\n })`\n }\n\n if (strict) {\n return `z.object({\n ${value}\n }).strict()`\n }\n\n return `z.object({\n ${value}\n })`\n },\n string: (coercion?: boolean, min?: number, max?: number) => {\n return [coercion ? 'z.coerce.string()' : 'z.string()', min !== undefined ? `.min(${min})` : undefined, max !== undefined ? `.max(${max})` : undefined]\n .filter(Boolean)\n .join('')\n },\n //support for discriminatedUnion\n boolean: () => 'z.boolean()',\n undefined: () => 'z.undefined()',\n nullable: (value?: string) => {\n if (value) {\n return `z.nullable(${value})`\n }\n return '.nullable()'\n },\n null: () => 'z.null()',\n nullish: (value?: string) => {\n if (value) {\n return `z.nullish(${value})`\n }\n return '.nullish()'\n },\n array: (items: string[] = [], min?: number, max?: number, unique?: boolean) => {\n return [\n `z.array(${items?.join('')})`,\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n unique ? `.refine(items => new Set(items).size === items.length, { message: \"Array entries must be unique\" })` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n tuple: (items: string[] = []) => `z.tuple([${items?.join(', ')}])`,\n enum: (items: string[] = []) => `z.enum([${items?.join(', ')}])`,\n union: (items: string[] = []) => `z.union([${items?.join(', ')}])`,\n const: (value?: string | number | boolean) => `z.literal(${value ?? ''})`,\n /**\n * ISO 8601\n */\n datetime: (offset = false, local = false, version: '3' | '4' = '3') => {\n if (offset) {\n return version === '4' ? `z.iso.datetime({ offset: ${offset} })` : `z.string().datetime({ offset: ${offset} })`\n }\n\n if (local) {\n return version === '4' ? `z.iso.datetime({ local: ${local} })` : `z.string().datetime({ local: ${local} })`\n }\n\n return 'z.string().datetime()'\n },\n /**\n * Type `'date'` Date\n * Type `'string'` ISO date format (YYYY-MM-DD)\n * @default ISO date format (YYYY-MM-DD)\n */\n date: (type: 'date' | 'string' = 'string', coercion?: boolean, version: '3' | '4' = '3') => {\n if (type === 'string') {\n return version === '4' ? 'z.iso.date()' : 'z.string().date()'\n }\n\n if (coercion) {\n return 'z.coerce.date()'\n }\n\n return 'z.date()'\n },\n /**\n * Type `'date'` Date\n * Type `'string'` ISO time format (HH:mm:ss[.SSSSSS])\n * @default ISO time format (HH:mm:ss[.SSSSSS])\n */\n time: (type: 'date' | 'string' = 'string', coercion?: boolean, version: '3' | '4' = '3') => {\n if (type === 'string') {\n return version === '4' ? 'z.iso.time()' : 'z.string().time()'\n }\n\n if (coercion) {\n return 'z.coerce.date()'\n }\n\n return 'z.date()'\n },\n uuid: (coercion?: boolean, version: '3' | '4' = '3', min?: number, max?: number) => {\n return [\n coercion ? 'z.coerce.string().uuid()' : version === '4' ? 'z.uuid()' : 'z.string().uuid()',\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n url: (coercion?: boolean, version: '3' | '4' = '3', min?: number, max?: number) => {\n return [\n coercion ? 'z.coerce.string().url()' : version === '4' ? 'z.url()' : 'z.string().url()',\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n default: (value?: string | number | true | object) => {\n if (typeof value === 'object') {\n return '.default({})'\n }\n return `.default(${value ?? ''})`\n },\n and: (items: string[] = []) => items?.map((item) => `.and(${item})`).join(''),\n describe: (value = '') => `.describe(${value})`,\n max: undefined,\n min: undefined,\n optional: (value?: string) => {\n if (value) {\n return `z.optional(${value})`\n }\n return '.optional()'\n },\n matches: (value = '', coercion?: boolean) => (coercion ? `z.coerce.string().regex(${value})` : `z.string().regex(${value})`),\n email: (coercion?: boolean, version: '3' | '4' = '3', min?: number, max?: number) => {\n return [\n coercion ? 'z.coerce.string().email()' : version === '4' ? 'z.email()' : 'z.string().email()',\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n firstName: undefined,\n lastName: undefined,\n password: undefined,\n phone: undefined,\n readOnly: undefined,\n writeOnly: undefined,\n ref: (value?: string, version: '3' | '4' = '3') => {\n if (!value) {\n return undefined\n }\n\n return version === '4' ? value : `z.lazy(() => ${value})`\n },\n blob: () => 'z.instanceof(File)',\n deprecated: undefined,\n example: undefined,\n schema: undefined,\n catchall: (value?: string) => (value ? `.catchall(${value})` : undefined),\n name: undefined,\n exclusiveMinimum: undefined,\n exclusiveMaximum: undefined,\n} satisfies SchemaMapper<string | null | undefined>\n\n/**\n * @link based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n */\n\nexport function sort(items?: Schema[]): Schema[] {\n const order: string[] = [\n schemaKeywords.string,\n schemaKeywords.datetime,\n schemaKeywords.date,\n schemaKeywords.time,\n schemaKeywords.tuple,\n schemaKeywords.number,\n schemaKeywords.object,\n schemaKeywords.enum,\n schemaKeywords.url,\n schemaKeywords.email,\n schemaKeywords.firstName,\n schemaKeywords.lastName,\n schemaKeywords.password,\n schemaKeywords.matches,\n schemaKeywords.uuid,\n schemaKeywords.null,\n schemaKeywords.min,\n schemaKeywords.max,\n schemaKeywords.default,\n schemaKeywords.describe,\n schemaKeywords.optional,\n schemaKeywords.nullable,\n schemaKeywords.nullish,\n ]\n\n if (!items) {\n return []\n }\n\n return transformers.orderBy(items, [(v) => order.indexOf(v.keyword)], ['asc'])\n}\n\nconst shouldCoerce = (coercion: ParserOptions['coercion'] | undefined, type: 'dates' | 'strings' | 'numbers'): boolean => {\n if (coercion === undefined) {\n return false\n }\n if (typeof coercion === 'boolean') {\n return coercion\n }\n\n return !!coercion[type]\n}\n\ntype ParserOptions = {\n name: string\n typeName?: string\n description?: string\n keysToOmit?: string[]\n mapper?: Record<string, string>\n coercion?: boolean | { dates?: boolean; strings?: boolean; numbers?: boolean }\n wrapOutput?: (opts: { output: string; schema: any }) => string | undefined\n rawSchema: SchemaObject\n version: '3' | '4'\n}\n\nexport function parse({ parent, current, name, siblings }: SchemaTree, options: ParserOptions): string | undefined {\n const value = zodKeywordMapper[current.keyword as keyof typeof zodKeywordMapper]\n\n // Early exit: if siblings contain both matches and ref → skip matches entirely\n const hasMatches = siblings.some((it) => isKeyword(it, schemaKeywords.matches))\n const hasRef = siblings.some((it) => isKeyword(it, schemaKeywords.ref))\n\n if (hasMatches && hasRef && isKeyword(current, schemaKeywords.matches)) {\n return undefined // strip matches\n }\n\n if (!value) {\n return undefined\n }\n\n if (isKeyword(current, schemaKeywords.union)) {\n // zod union type needs at least 2 items\n if (Array.isArray(current.args) && current.args.length === 1) {\n return parse({ parent, name: name, current: current.args[0] as Schema, siblings }, options)\n }\n if (Array.isArray(current.args) && !current.args.length) {\n return ''\n }\n\n return zodKeywordMapper.union(\n sort(current.args)\n .map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean),\n )\n }\n\n if (isKeyword(current, schemaKeywords.and)) {\n const items = sort(current.args)\n .filter((schema: Schema) => {\n return ![schemaKeywords.optional, schemaKeywords.describe].includes(schema.keyword as typeof schemaKeywords.describe)\n })\n .map((schema: Schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean)\n\n return `${items.slice(0, 1)}${zodKeywordMapper.and(items.slice(1))}`\n }\n\n if (isKeyword(current, schemaKeywords.array)) {\n return zodKeywordMapper.array(\n sort(current.args.items)\n .map((schemas, _index, siblings) => parse({ parent: current, name: name, current: schemas, siblings }, options))\n .filter(Boolean),\n current.args.min,\n current.args.max,\n current.args.unique,\n )\n }\n\n if (isKeyword(current, schemaKeywords.enum)) {\n if (current.args.asConst) {\n if (current.args.items.length === 1) {\n const child = {\n keyword: schemaKeywords.const,\n args: current.args.items[0],\n }\n return parse({ parent: current, name: name, current: child, siblings: [child] }, options)\n }\n\n return zodKeywordMapper.union(\n current.args.items\n .map((schema) => ({\n keyword: schemaKeywords.const,\n args: schema,\n }))\n .map((schema, _index, siblings) => {\n return parse({ parent: current, name: name, current: schema, siblings }, options)\n })\n .filter(Boolean),\n )\n }\n\n return zodKeywordMapper.enum(\n current.args.items.map((schema) => {\n if (schema.format === 'boolean') {\n return transformers.stringify(schema.value)\n }\n\n if (schema.format === 'number') {\n return transformers.stringify(schema.value)\n }\n return transformers.stringify(schema.value)\n }),\n )\n }\n\n if (isKeyword(current, schemaKeywords.ref)) {\n return zodKeywordMapper.ref(current.args?.name, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.object)) {\n const propertyEntries = Object.entries(current.args?.properties || {}).filter((item) => {\n const schema = item[1]\n return schema && typeof schema.map === 'function'\n })\n\n const properties = propertyEntries\n .map(([name, schemas]) => {\n const nameSchema = schemas.find((it) => it.keyword === schemaKeywords.name) as SchemaKeywordMapper['name']\n const isNullable = schemas.some((it) => isKeyword(it, schemaKeywords.nullable))\n const isNullish = schemas.some((it) => isKeyword(it, schemaKeywords.nullish))\n const isOptional = schemas.some((it) => isKeyword(it, schemaKeywords.optional))\n\n const mappedName = nameSchema?.args || name\n\n // custom mapper(pluginOptions)\n if (options.mapper?.[mappedName]) {\n return `\"${name}\": ${options.mapper?.[mappedName]}`\n }\n\n const baseSchemaOutput = sort(schemas)\n .filter((schema) => {\n return !isKeyword(schema, schemaKeywords.optional) && !isKeyword(schema, schemaKeywords.nullable) && !isKeyword(schema, schemaKeywords.nullish)\n })\n .map((schema) => parse({ parent: current, name, current: schema, siblings: schemas }, options))\n .filter(Boolean)\n .join('')\n\n const objectValue = options.wrapOutput\n ? options.wrapOutput({ output: baseSchemaOutput, schema: options.rawSchema?.properties?.[name] }) || baseSchemaOutput\n : baseSchemaOutput\n\n if (options.version === '4' && SchemaGenerator.find(schemas, schemaKeywords.ref)) {\n // both optional and nullable\n if (isNullish) {\n return `get \"${name}\"(){\n return ${zodKeywordMapper.nullish(objectValue)}\n }`\n }\n\n // undefined\n if (isOptional) {\n return `get \"${name}\"(){\n return ${zodKeywordMapper.optional(objectValue)}\n }`\n }\n\n // null\n if (isNullable) {\n return `get \"${name}\"(){\n return ${zodKeywordMapper.nullable(objectValue)}\n }`\n }\n\n return `get \"${name}\"(){\n return ${objectValue}\n }`\n }\n\n // both optional and nullable\n if (isNullish) {\n return `\"${name}\": ${objectValue}${zodKeywordMapper.nullish()}`\n }\n\n // undefined\n if (isOptional) {\n return `\"${name}\": ${zodKeywordMapper.optional(objectValue)}`\n }\n\n // null\n if (isNullable) {\n return `\"${name}\": ${zodKeywordMapper.nullable(objectValue)}`\n }\n\n return `\"${name}\": ${objectValue}`\n })\n .join(',\\n')\n\n const additionalProperties = current.args?.additionalProperties?.length\n ? current.args.additionalProperties\n .map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean)\n .join('')\n : undefined\n\n const text = [\n zodKeywordMapper.object(properties, current.args?.strict, options.version),\n additionalProperties ? zodKeywordMapper.catchall(additionalProperties) : undefined,\n ].filter(Boolean)\n\n return text.join('')\n }\n\n if (isKeyword(current, schemaKeywords.tuple)) {\n return zodKeywordMapper.tuple(\n current.args.items.map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options)).filter(Boolean),\n )\n }\n\n if (isKeyword(current, schemaKeywords.const)) {\n if (current.args.format === 'number' && current.args.value !== undefined) {\n return zodKeywordMapper.const(Number(current.args.value))\n }\n\n if (current.args.format === 'boolean' && current.args.value !== undefined) {\n return zodKeywordMapper.const(current.args.value)\n }\n return zodKeywordMapper.const(transformers.stringify(current.args.value))\n }\n\n if (isKeyword(current, schemaKeywords.matches)) {\n if (current.args) {\n return zodKeywordMapper.matches(transformers.toRegExpString(current.args, null), shouldCoerce(options.coercion, 'strings'))\n }\n }\n\n if (isKeyword(current, schemaKeywords.default)) {\n if (current.args) {\n return zodKeywordMapper.default(current.args)\n }\n }\n\n if (isKeyword(current, schemaKeywords.describe)) {\n if (current.args) {\n return zodKeywordMapper.describe(transformers.stringify(current.args.toString()))\n }\n }\n\n if (isKeyword(current, schemaKeywords.string)) {\n const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min)\n const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max)\n\n return zodKeywordMapper.string(shouldCoerce(options.coercion, 'strings'), minSchema?.args, maxSchema?.args)\n }\n\n if (isKeyword(current, schemaKeywords.uuid)) {\n return zodKeywordMapper.uuid(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.email)) {\n const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min)\n const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max)\n\n return zodKeywordMapper.email(shouldCoerce(options.coercion, 'strings'), options.version, minSchema?.args, maxSchema?.args)\n }\n\n if (isKeyword(current, schemaKeywords.url)) {\n const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min)\n const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max)\n\n return zodKeywordMapper.url(shouldCoerce(options.coercion, 'strings'), options.version, minSchema?.args, maxSchema?.args)\n }\n\n if (isKeyword(current, schemaKeywords.number)) {\n const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min)\n const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max)\n\n const exclusiveMinimumSchema = SchemaGenerator.find(siblings, schemaKeywords.exclusiveMinimum)\n const exclusiveMaximumSchema = SchemaGenerator.find(siblings, schemaKeywords.exclusiveMaximum)\n return zodKeywordMapper.number(\n shouldCoerce(options.coercion, 'numbers'),\n minSchema?.args,\n maxSchema?.args,\n exclusiveMinimumSchema?.args,\n exclusiveMaximumSchema?.args,\n )\n }\n\n if (isKeyword(current, schemaKeywords.integer)) {\n const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min)\n const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max)\n\n const exclusiveMinimumSchema = SchemaGenerator.find(siblings, schemaKeywords.exclusiveMinimum)\n const exclusiveMaximumSchema = SchemaGenerator.find(siblings, schemaKeywords.exclusiveMaximum)\n return zodKeywordMapper.integer(\n shouldCoerce(options.coercion, 'numbers'),\n minSchema?.args,\n maxSchema?.args,\n options.version,\n exclusiveMinimumSchema?.args,\n exclusiveMaximumSchema?.args,\n )\n }\n\n if (isKeyword(current, schemaKeywords.datetime)) {\n return zodKeywordMapper.datetime(current.args.offset, current.args.local, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.date)) {\n return zodKeywordMapper.date(current.args.type, shouldCoerce(options.coercion, 'dates'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.time)) {\n return zodKeywordMapper.time(current.args.type, shouldCoerce(options.coercion, 'dates'), options.version)\n }\n\n if (current.keyword in zodKeywordMapper && 'args' in current) {\n const value = zodKeywordMapper[current.keyword as keyof typeof zodKeywordMapper] as (typeof zodKeywordMapper)['const']\n\n return value((current as SchemaKeywordBase<unknown>).args as any)\n }\n\n if (current.keyword in zodKeywordMapper) {\n return value()\n }\n\n return undefined\n}\n","import transformers from '@kubb/core/transformers'\nimport type { SchemaObject } from '@kubb/oas'\nimport { isKeyword, type Schema, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { Const, File, Type } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport * as parserZod from '../parser.ts'\nimport type { PluginZod } from '../types.ts'\n\ntype Props = {\n name: string\n typeName?: string\n inferTypeName?: string\n tree: Array<Schema>\n rawSchema: SchemaObject\n description?: string\n coercion: PluginZod['resolvedOptions']['coercion']\n mapper: PluginZod['resolvedOptions']['mapper']\n keysToOmit?: string[]\n wrapOutput?: PluginZod['resolvedOptions']['wrapOutput']\n version: '3' | '4'\n emptySchemaType: PluginZod['resolvedOptions']['emptySchemaType']\n}\n\nexport function Zod({\n name,\n typeName,\n tree,\n rawSchema,\n inferTypeName,\n mapper,\n coercion,\n keysToOmit,\n description,\n wrapOutput,\n version,\n emptySchemaType,\n}: Props): KubbNode {\n const hasTuple = !!SchemaGenerator.deepSearch(tree, schemaKeywords.tuple)\n\n const schemas = parserZod.sort(tree).filter((item) => {\n if (hasTuple && (isKeyword(item, schemaKeywords.min) || isKeyword(item, schemaKeywords.max))) {\n return false\n }\n\n return true\n })\n\n const output = schemas\n .map((schema, index) => {\n const siblings = schemas.filter((_, i) => i !== index)\n\n return parserZod.parse(\n { parent: undefined, current: schema, siblings },\n { name, keysToOmit, typeName, description, mapper, coercion, wrapOutput, rawSchema, version },\n )\n })\n .filter(Boolean)\n .join('')\n\n let suffix = ''\n const firstSchema = schemas.at(0)\n const lastSchema = schemas.at(-1)\n\n if (lastSchema && isKeyword(lastSchema, schemaKeywords.nullable)) {\n if (firstSchema && isKeyword(firstSchema, schemaKeywords.ref)) {\n if (version === '3') {\n suffix = '.unwrap().schema.unwrap()'\n } else {\n suffix = '.unwrap().unwrap()'\n }\n } else {\n suffix = '.unwrap()'\n }\n } else {\n if (firstSchema && isKeyword(firstSchema, schemaKeywords.ref) && version === '3') {\n suffix = '.schema'\n }\n }\n\n const emptyValue = parserZod.parse(\n {\n parent: undefined,\n current: {\n keyword: schemaKeywords[emptySchemaType],\n },\n siblings: [],\n },\n { name, keysToOmit, typeName, description, mapper, coercion, wrapOutput, rawSchema, version },\n )\n\n const baseSchemaOutput =\n [output, keysToOmit?.length ? `${suffix}.omit({ ${keysToOmit.map((key) => `'${key}': true`).join(',')} })` : undefined].filter(Boolean).join('') ||\n emptyValue ||\n ''\n const wrappedSchemaOutput = wrapOutput ? wrapOutput({ output: baseSchemaOutput, schema: rawSchema }) || baseSchemaOutput : baseSchemaOutput\n const finalOutput = typeName ? `${wrappedSchemaOutput} as unknown as ${version === '4' ? 'z.ZodType' : 'ToZod'}<${typeName}>` : wrappedSchemaOutput\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Const\n export\n name={name}\n JSDoc={{\n comments: [description ? `@description ${transformers.jsStringEscape(description)}` : undefined].filter(Boolean),\n }}\n >\n {finalOutput}\n </Const>\n </File.Source>\n {inferTypeName && (\n <File.Source name={inferTypeName} isExportable isIndexable isTypeOnly>\n {typeName && (\n <Type export name={inferTypeName}>\n {typeName}\n </Type>\n )}\n {!typeName && (\n <Type export name={inferTypeName}>\n {`z.infer<typeof ${name}>`}\n </Type>\n )}\n </File.Source>\n )}\n </>\n )\n}\n"],"m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