@kubb/plugin-zod 3.5.7 → 3.5.8
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.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/index.cjs +4 -3
- 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 +4 -3
- package/dist/index.js.map +1 -1
- package/dist/{types-BS3p0dlS.d.cts → types-PnaUmUK7.d.cts} +6 -1
- package/dist/{types-BS3p0dlS.d.ts → types-PnaUmUK7.d.ts} +6 -1
- package/package.json +10 -10
- package/src/plugin.ts +3 -2
- package/src/types.ts +6 -1
package/dist/components.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SchemaNames } from '@kubb/plugin-oas/hooks';
|
|
2
2
|
import { Operation } from '@kubb/oas';
|
|
3
3
|
import { Schema } from '@kubb/plugin-oas';
|
|
4
|
-
import { P as PluginZod } from './types-
|
|
4
|
+
import { P as PluginZod } from './types-PnaUmUK7.cjs';
|
|
5
5
|
import '@kubb/core';
|
|
6
6
|
|
|
7
7
|
type Props$1 = {
|
package/dist/components.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SchemaNames } from '@kubb/plugin-oas/hooks';
|
|
2
2
|
import { Operation } from '@kubb/oas';
|
|
3
3
|
import { Schema } from '@kubb/plugin-oas';
|
|
4
|
-
import { P as PluginZod } from './types-
|
|
4
|
+
import { P as PluginZod } from './types-PnaUmUK7.js';
|
|
5
5
|
import '@kubb/core';
|
|
6
6
|
|
|
7
7
|
type Props$1 = {
|
package/dist/generators.d.cts
CHANGED
package/dist/generators.d.ts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -29,7 +29,8 @@ var pluginZod = core.createPlugin((options) => {
|
|
|
29
29
|
importPath = "zod",
|
|
30
30
|
coercion = false,
|
|
31
31
|
inferred = false,
|
|
32
|
-
generators = [chunk6N5S7RR7_cjs.zodGenerator, operations ? chunk6N5S7RR7_cjs.operationsGenerator : undefined].filter(Boolean)
|
|
32
|
+
generators = [chunk6N5S7RR7_cjs.zodGenerator, operations ? chunk6N5S7RR7_cjs.operationsGenerator : undefined].filter(Boolean),
|
|
33
|
+
contentType
|
|
33
34
|
} = options;
|
|
34
35
|
return {
|
|
35
36
|
name: pluginZodName,
|
|
@@ -96,7 +97,7 @@ var pluginZod = core.createPlugin((options) => {
|
|
|
96
97
|
oas,
|
|
97
98
|
pluginManager: this.pluginManager,
|
|
98
99
|
plugin: this.plugin,
|
|
99
|
-
contentType
|
|
100
|
+
contentType,
|
|
100
101
|
include: undefined,
|
|
101
102
|
override,
|
|
102
103
|
mode,
|
|
@@ -108,7 +109,7 @@ var pluginZod = core.createPlugin((options) => {
|
|
|
108
109
|
oas,
|
|
109
110
|
pluginManager: this.pluginManager,
|
|
110
111
|
plugin: this.plugin,
|
|
111
|
-
contentType
|
|
112
|
+
contentType,
|
|
112
113
|
exclude,
|
|
113
114
|
include,
|
|
114
115
|
override,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"names":["createPlugin","transformers","zodGenerator","operationsGenerator","pluginOasName","pluginTsName","options","path","FileManager","camelCase","pascalCase","PluginManager","SchemaGenerator","OperationGenerator"],"mappings":";;;;;;;;;;;;;;AAcO,IAAM,aAAgB,GAAA;AAEhB,IAAA,SAAA,GAAYA,iBAAwB,CAAA,CAAC,OAAY,KAAA;AAC5D,EAAM,MAAA;AAAA,IACJ,MAAS,GAAA,EAAE,IAAM,EAAA,KAAA,EAAO,YAAY,OAAQ,EAAA;AAAA,IAC5C,KAAA;AAAA,IACA,UAAU,EAAC;AAAA,IACX,OAAA;AAAA,IACA,WAAW,EAAC;AAAA,kBACZC,iBAAe,EAAC;AAAA,IAChB,QAAW,GAAA,QAAA;AAAA,IACX,WAAc,GAAA,KAAA;AAAA,IACd,KAAQ,GAAA,KAAA;AAAA,IACR,SAAS,EAAC;AAAA,IACV,UAAa,GAAA,KAAA;AAAA,IACb,UAAa,GAAA,KAAA;AAAA,IACb,QAAW,GAAA,KAAA;AAAA,IACX,QAAW,GAAA,KAAA;AAAA,IACX,UAAA,GAAa,CAACC,8BAAc,EAAA,UAAA,GAAaC,wCAAsB,SAAS,CAAA,CAAE,OAAO,OAAO;AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"names":["createPlugin","transformers","zodGenerator","operationsGenerator","pluginOasName","pluginTsName","options","path","FileManager","camelCase","pascalCase","PluginManager","SchemaGenerator","OperationGenerator"],"mappings":";;;;;;;;;;;;;;AAcO,IAAM,aAAgB,GAAA;AAEhB,IAAA,SAAA,GAAYA,iBAAwB,CAAA,CAAC,OAAY,KAAA;AAC5D,EAAM,MAAA;AAAA,IACJ,MAAS,GAAA,EAAE,IAAM,EAAA,KAAA,EAAO,YAAY,OAAQ,EAAA;AAAA,IAC5C,KAAA;AAAA,IACA,UAAU,EAAC;AAAA,IACX,OAAA;AAAA,IACA,WAAW,EAAC;AAAA,kBACZC,iBAAe,EAAC;AAAA,IAChB,QAAW,GAAA,QAAA;AAAA,IACX,WAAc,GAAA,KAAA;AAAA,IACd,KAAQ,GAAA,KAAA;AAAA,IACR,SAAS,EAAC;AAAA,IACV,UAAa,GAAA,KAAA;AAAA,IACb,UAAa,GAAA,KAAA;AAAA,IACb,QAAW,GAAA,KAAA;AAAA,IACX,QAAW,GAAA,KAAA;AAAA,IACX,UAAA,GAAa,CAACC,8BAAc,EAAA,UAAA,GAAaC,wCAAsB,SAAS,CAAA,CAAE,OAAO,OAAO,CAAA;AAAA,IACxF;AAAA,GACE,GAAA,OAAA;AAEJ,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,aAAA;AAAA,IACN,OAAS,EAAA;AAAA,MACP,MAAA;AAAA,oBACAF,cAAA;AAAA,MACA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nC,GACF;AACF,CAAC","file":"index.cjs","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { OperationGenerator, SchemaGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { operationsGenerator } from './generators'\nimport { zodGenerator } from './generators/zodGenerator.tsx'\nimport type { PluginZod } from './types.ts'\n\nexport const pluginZodName = 'plugin-zod' satisfies PluginZod['name']\n\nexport const pluginZod = createPlugin<PluginZod>((options) => {\n const {\n output = { path: 'zod', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dateType = 'string',\n unknownType = 'any',\n typed = false,\n mapper = {},\n operations = false,\n importPath = 'zod',\n coercion = false,\n inferred = false,\n generators = [zodGenerator, operations ? operationsGenerator : undefined].filter(Boolean),\n contentType,\n } = options\n\n return {\n name: pluginZodName,\n options: {\n output,\n transformers,\n include,\n exclude,\n override,\n typed,\n dateType,\n unknownType,\n mapper,\n importPath,\n coercion,\n operations,\n inferred,\n group,\n },\n pre: [pluginOasName, typed ? pluginTsName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name, {\n suffix: type ? 'schema' : undefined,\n isFile: type === 'file',\n })\n\n if (type === 'type') {\n resolvedName = pascalCase(resolvedName)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n await this.addFile(...operationFiles)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"]}
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -23,7 +23,8 @@ var pluginZod = createPlugin((options) => {
|
|
|
23
23
|
importPath = "zod",
|
|
24
24
|
coercion = false,
|
|
25
25
|
inferred = false,
|
|
26
|
-
generators = [zodGenerator, operations ? operationsGenerator : undefined].filter(Boolean)
|
|
26
|
+
generators = [zodGenerator, operations ? operationsGenerator : undefined].filter(Boolean),
|
|
27
|
+
contentType
|
|
27
28
|
} = options;
|
|
28
29
|
return {
|
|
29
30
|
name: pluginZodName,
|
|
@@ -90,7 +91,7 @@ var pluginZod = createPlugin((options) => {
|
|
|
90
91
|
oas,
|
|
91
92
|
pluginManager: this.pluginManager,
|
|
92
93
|
plugin: this.plugin,
|
|
93
|
-
contentType
|
|
94
|
+
contentType,
|
|
94
95
|
include: undefined,
|
|
95
96
|
override,
|
|
96
97
|
mode,
|
|
@@ -102,7 +103,7 @@ var pluginZod = createPlugin((options) => {
|
|
|
102
103
|
oas,
|
|
103
104
|
pluginManager: this.pluginManager,
|
|
104
105
|
plugin: this.plugin,
|
|
105
|
-
contentType
|
|
106
|
+
contentType,
|
|
106
107
|
exclude,
|
|
107
108
|
include,
|
|
108
109
|
override,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"names":["options"],"mappings":";;;;;;;;AAcO,IAAM,aAAgB,GAAA;AAEhB,IAAA,SAAA,GAAY,YAAwB,CAAA,CAAC,OAAY,KAAA;AAC5D,EAAM,MAAA;AAAA,IACJ,MAAS,GAAA,EAAE,IAAM,EAAA,KAAA,EAAO,YAAY,OAAQ,EAAA;AAAA,IAC5C,KAAA;AAAA,IACA,UAAU,EAAC;AAAA,IACX,OAAA;AAAA,IACA,WAAW,EAAC;AAAA,IACZ,eAAe,EAAC;AAAA,IAChB,QAAW,GAAA,QAAA;AAAA,IACX,WAAc,GAAA,KAAA;AAAA,IACd,KAAQ,GAAA,KAAA;AAAA,IACR,SAAS,EAAC;AAAA,IACV,UAAa,GAAA,KAAA;AAAA,IACb,UAAa,GAAA,KAAA;AAAA,IACb,QAAW,GAAA,KAAA;AAAA,IACX,QAAW,GAAA,KAAA;AAAA,IACX,UAAA,GAAa,CAAC,YAAc,EAAA,UAAA,GAAa,sBAAsB,SAAS,CAAA,CAAE,OAAO,OAAO;AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"names":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AAS,EAAA;AAAA,QACrE,GAAA;AAAA,QACA,eAAe,IAAK,CAAA,aAAA;AAAA,QACpB,QAAQ,IAAK,CAAA,MAAA;AAAA,QACb,WAAA;AAAA,QACA,OAAA;AAAA,QACA,OAAA;AAAA,QACA,QAAA;AAAA,QACA;AAAA,OACD,CAAA;AAED,MAAA,MAAM,cAAiB,GAAA,MAAM,kBAAmB,CAAA,KAAA,CAAM,GAAG,UAAU,CAAA;AACnE,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,cAAc,CAAA;AAEpC,MAAA,MAAM,WAAc,GAAA,MAAM,IAAK,CAAA,WAAA,CAAY,cAAe,CAAA;AAAA,QACxD,IAAA,EAAM,OAAO,UAAc,IAAA,OAAA;AAAA,QAC3B,IAAA;AAAA,QACA,MAAA;AAAA,QACA,KAAA,EAAO,KAAK,WAAY,CAAA,KAAA;AAAA,QACxB,IAAM,EAAA;AAAA,UACJ,SAAA,EAAW,KAAK,MAAO,CAAA;AAAA,SACzB;AAAA,QACA,QAAQ,IAAK,CAAA;AAAA,OACd,CAAA;AAED,MAAM,MAAA,IAAA,CAAK,OAAQ,CAAA,GAAG,WAAW,CAAA;AAAA;AACnC,GACF;AACF,CAAC","file":"index.js","sourcesContent":["import path from 'node:path'\n\nimport { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'\nimport { camelCase, pascalCase } from '@kubb/core/transformers'\nimport { OperationGenerator, SchemaGenerator, pluginOasName } from '@kubb/plugin-oas'\n\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport type { Plugin } from '@kubb/core'\nimport type { PluginOas as SwaggerPluginOptions } from '@kubb/plugin-oas'\nimport { operationsGenerator } from './generators'\nimport { zodGenerator } from './generators/zodGenerator.tsx'\nimport type { PluginZod } from './types.ts'\n\nexport const pluginZodName = 'plugin-zod' satisfies PluginZod['name']\n\nexport const pluginZod = createPlugin<PluginZod>((options) => {\n const {\n output = { path: 'zod', barrelType: 'named' },\n group,\n exclude = [],\n include,\n override = [],\n transformers = {},\n dateType = 'string',\n unknownType = 'any',\n typed = false,\n mapper = {},\n operations = false,\n importPath = 'zod',\n coercion = false,\n inferred = false,\n generators = [zodGenerator, operations ? operationsGenerator : undefined].filter(Boolean),\n contentType,\n } = options\n\n return {\n name: pluginZodName,\n options: {\n output,\n transformers,\n include,\n exclude,\n override,\n typed,\n dateType,\n unknownType,\n mapper,\n importPath,\n coercion,\n operations,\n inferred,\n group,\n },\n pre: [pluginOasName, typed ? pluginTsName : undefined].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Controller`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n let resolvedName = camelCase(name, {\n suffix: type ? 'schema' : undefined,\n isFile: type === 'file',\n })\n\n if (type === 'type') {\n resolvedName = pascalCase(resolvedName)\n }\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async buildStart() {\n const [swaggerPlugin]: [Plugin<SwaggerPluginOptions>] = PluginManager.getDependedPlugins<SwaggerPluginOptions>(this.plugins, [pluginOasName])\n\n const oas = await swaggerPlugin.context.getOas()\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = FileManager.getMode(path.resolve(root, output.path))\n\n const schemaGenerator = new SchemaGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n include: undefined,\n override,\n mode,\n output: output.path,\n })\n\n const schemaFiles = await schemaGenerator.build(...generators)\n await this.addFile(...schemaFiles)\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n oas,\n pluginManager: this.pluginManager,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const operationFiles = await operationGenerator.build(...generators)\n await this.addFile(...operationFiles)\n\n const barrelFiles = await this.fileManager.getBarrelFiles({\n type: output.barrelType ?? 'named',\n root,\n output,\n files: this.fileManager.files,\n meta: {\n pluginKey: this.plugin.key,\n },\n logger: this.logger,\n })\n\n await this.addFile(...barrelFiles)\n },\n }\n})\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
|
|
2
|
-
import { Oas, SchemaObject } from '@kubb/oas';
|
|
2
|
+
import { Oas, contentType, SchemaObject } from '@kubb/oas';
|
|
3
3
|
import { ResolvePathOptions, Exclude, Include, Override, Schema, Generator } from '@kubb/plugin-oas';
|
|
4
4
|
|
|
5
5
|
type Options = {
|
|
@@ -7,6 +7,11 @@ type Options = {
|
|
|
7
7
|
* @default 'zod'
|
|
8
8
|
*/
|
|
9
9
|
output?: Output<Oas>;
|
|
10
|
+
/**
|
|
11
|
+
* Define which contentType should be used.
|
|
12
|
+
* By default, the first JSON valid mediaType will be used
|
|
13
|
+
*/
|
|
14
|
+
contentType?: contentType;
|
|
10
15
|
/**
|
|
11
16
|
* Group the Zod schemas based on the provided name.
|
|
12
17
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
|
|
2
|
-
import { Oas, SchemaObject } from '@kubb/oas';
|
|
2
|
+
import { Oas, contentType, SchemaObject } from '@kubb/oas';
|
|
3
3
|
import { ResolvePathOptions, Exclude, Include, Override, Schema, Generator } from '@kubb/plugin-oas';
|
|
4
4
|
|
|
5
5
|
type Options = {
|
|
@@ -7,6 +7,11 @@ type Options = {
|
|
|
7
7
|
* @default 'zod'
|
|
8
8
|
*/
|
|
9
9
|
output?: Output<Oas>;
|
|
10
|
+
/**
|
|
11
|
+
* Define which contentType should be used.
|
|
12
|
+
* By default, the first JSON valid mediaType will be used
|
|
13
|
+
*/
|
|
14
|
+
contentType?: contentType;
|
|
10
15
|
/**
|
|
11
16
|
* Group the Zod schemas based on the provided name.
|
|
12
17
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-zod",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.8",
|
|
4
4
|
"description": "Generator plugin-zod",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -66,19 +66,19 @@
|
|
|
66
66
|
"!/**/__tests__/**"
|
|
67
67
|
],
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@kubb/core": "3.5.
|
|
70
|
-
"@kubb/fs": "3.5.
|
|
71
|
-
"@kubb/oas": "3.5.
|
|
72
|
-
"@kubb/parser-ts": "3.5.
|
|
73
|
-
"@kubb/plugin-oas": "3.5.
|
|
74
|
-
"@kubb/plugin-ts": "3.5.
|
|
75
|
-
"@kubb/react": "3.5.
|
|
69
|
+
"@kubb/core": "3.5.8",
|
|
70
|
+
"@kubb/fs": "3.5.8",
|
|
71
|
+
"@kubb/oas": "3.5.8",
|
|
72
|
+
"@kubb/parser-ts": "3.5.8",
|
|
73
|
+
"@kubb/plugin-oas": "3.5.8",
|
|
74
|
+
"@kubb/plugin-ts": "3.5.8",
|
|
75
|
+
"@kubb/react": "3.5.8"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"tsup": "^8.3.6",
|
|
79
79
|
"zod": "~3.24.1",
|
|
80
|
-
"@kubb/config-
|
|
81
|
-
"@kubb/config-
|
|
80
|
+
"@kubb/config-ts": "3.5.8",
|
|
81
|
+
"@kubb/config-tsup": "3.5.8"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
84
|
"@kubb/react": "^3.0.0"
|
package/src/plugin.ts
CHANGED
|
@@ -31,6 +31,7 @@ export const pluginZod = createPlugin<PluginZod>((options) => {
|
|
|
31
31
|
coercion = false,
|
|
32
32
|
inferred = false,
|
|
33
33
|
generators = [zodGenerator, operations ? operationsGenerator : undefined].filter(Boolean),
|
|
34
|
+
contentType,
|
|
34
35
|
} = options
|
|
35
36
|
|
|
36
37
|
return {
|
|
@@ -113,7 +114,7 @@ export const pluginZod = createPlugin<PluginZod>((options) => {
|
|
|
113
114
|
oas,
|
|
114
115
|
pluginManager: this.pluginManager,
|
|
115
116
|
plugin: this.plugin,
|
|
116
|
-
contentType
|
|
117
|
+
contentType,
|
|
117
118
|
include: undefined,
|
|
118
119
|
override,
|
|
119
120
|
mode,
|
|
@@ -127,7 +128,7 @@ export const pluginZod = createPlugin<PluginZod>((options) => {
|
|
|
127
128
|
oas,
|
|
128
129
|
pluginManager: this.pluginManager,
|
|
129
130
|
plugin: this.plugin,
|
|
130
|
-
contentType
|
|
131
|
+
contentType,
|
|
131
132
|
exclude,
|
|
132
133
|
include,
|
|
133
134
|
override,
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Group, Output, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
|
|
2
|
-
import type { Oas, SchemaObject } from '@kubb/oas'
|
|
2
|
+
import type { Oas, SchemaObject, contentType } from '@kubb/oas'
|
|
3
3
|
import type { Exclude, Generator, Include, Override, ResolvePathOptions, Schema } from '@kubb/plugin-oas'
|
|
4
4
|
|
|
5
5
|
export type Options = {
|
|
@@ -7,6 +7,11 @@ export type Options = {
|
|
|
7
7
|
* @default 'zod'
|
|
8
8
|
*/
|
|
9
9
|
output?: Output<Oas>
|
|
10
|
+
/**
|
|
11
|
+
* Define which contentType should be used.
|
|
12
|
+
* By default, the first JSON valid mediaType will be used
|
|
13
|
+
*/
|
|
14
|
+
contentType?: contentType
|
|
10
15
|
/**
|
|
11
16
|
* Group the Zod schemas based on the provided name.
|
|
12
17
|
*/
|