@kubb/plugin-zod 3.5.6 → 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/{chunk-ZCFIE7QM.cjs → chunk-6N5S7RR7.cjs} +12 -12
- package/dist/chunk-6N5S7RR7.cjs.map +1 -0
- package/dist/{chunk-5FGCOG4Y.js → chunk-CPI4DGDT.js} +34 -34
- package/dist/chunk-CPI4DGDT.js.map +1 -0
- package/dist/{chunk-56YVG5T4.cjs → chunk-E2BLKQJO.cjs} +34 -34
- package/dist/chunk-E2BLKQJO.cjs.map +1 -0
- package/dist/{chunk-KYYFTIXW.js → chunk-LBZ6BUKN.js} +9 -9
- package/dist/chunk-LBZ6BUKN.js.map +1 -0
- package/dist/components.cjs +3 -3
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/generators.cjs +4 -4
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +9 -8
- 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 +9 -8
- 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 +11 -11
- package/src/components/Operations.tsx +0 -1
- package/src/components/Zod.tsx +0 -1
- package/src/parser.ts +1 -1
- package/src/plugin.ts +3 -2
- package/src/types.ts +6 -1
- package/dist/chunk-56YVG5T4.cjs.map +0 -1
- package/dist/chunk-5FGCOG4Y.js.map +0 -1
- package/dist/chunk-KYYFTIXW.js.map +0 -1
- package/dist/chunk-ZCFIE7QM.cjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Zod, Operations } from './chunk-
|
|
1
|
+
import { Zod, Operations } from './chunk-CPI4DGDT.js';
|
|
2
2
|
import { createReactGenerator, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas';
|
|
3
3
|
import { Oas } from '@kubb/plugin-oas/components';
|
|
4
4
|
import { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks';
|
|
@@ -28,9 +28,9 @@ var zodGenerator = createReactGenerator({
|
|
|
28
28
|
const mapOperationSchema = ({ name, schema, description, keysToOmit, ...options2 }, i) => {
|
|
29
29
|
const required = Array.isArray(schema?.required) ? !!schema.required.length : !!schema?.required;
|
|
30
30
|
const optional = !required && name.includes("Params");
|
|
31
|
-
const tree = [...schemaGenerator.parse({ schema, name }), optional ? { keyword: schemaKeywords.optional } :
|
|
31
|
+
const tree = [...schemaGenerator.parse({ schema, name }), optional ? { keyword: schemaKeywords.optional } : undefined].filter(Boolean);
|
|
32
32
|
const imports = schemaManager.getImports(tree);
|
|
33
|
-
const group = options2.operation ? getGroup(options2.operation) :
|
|
33
|
+
const group = options2.operation ? getGroup(options2.operation) : undefined;
|
|
34
34
|
const zod = {
|
|
35
35
|
name: schemaManager.getName(name, { type: "function" }),
|
|
36
36
|
inferTypeName: schemaManager.getName(name, { type: "type" }),
|
|
@@ -48,8 +48,8 @@ var zodGenerator = createReactGenerator({
|
|
|
48
48
|
Zod,
|
|
49
49
|
{
|
|
50
50
|
name: zod.name,
|
|
51
|
-
typeName: typed ? type.name :
|
|
52
|
-
inferTypeName: inferred ? zod.inferTypeName :
|
|
51
|
+
typeName: typed ? type.name : undefined,
|
|
52
|
+
inferTypeName: inferred ? zod.inferTypeName : undefined,
|
|
53
53
|
description,
|
|
54
54
|
tree,
|
|
55
55
|
mapper,
|
|
@@ -102,8 +102,8 @@ var zodGenerator = createReactGenerator({
|
|
|
102
102
|
Zod,
|
|
103
103
|
{
|
|
104
104
|
name: zod.name,
|
|
105
|
-
typeName: typed ? type.name :
|
|
106
|
-
inferTypeName: inferred ? zod.inferTypeName :
|
|
105
|
+
typeName: typed ? type.name : undefined,
|
|
106
|
+
inferTypeName: inferred ? zod.inferTypeName : undefined,
|
|
107
107
|
description: schema.value.description,
|
|
108
108
|
tree: schema.tree,
|
|
109
109
|
mapper,
|
|
@@ -140,5 +140,5 @@ var operationsGenerator = createReactGenerator({
|
|
|
140
140
|
});
|
|
141
141
|
|
|
142
142
|
export { operationsGenerator, zodGenerator };
|
|
143
|
-
//# sourceMappingURL=chunk-
|
|
144
|
-
//# sourceMappingURL=chunk-
|
|
143
|
+
//# sourceMappingURL=chunk-LBZ6BUKN.js.map
|
|
144
|
+
//# sourceMappingURL=chunk-LBZ6BUKN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/generators/zodGenerator.tsx","../src/generators/operationsGenerator.tsx"],"names":["options","createReactGenerator","useApp","useOas","useOperationManager","jsx","File","jsxs","getBanner","getFooter"],"mappings":";;;;;;;;;AASO,IAAM,eAAe,oBAAgC,CAAA;AAAA,EAC1D,IAAM,EAAA,KAAA;AAAA,EACN,SAAU,CAAA,EAAE,SAAW,EAAA,OAAA,EAAW,EAAA;AAChC,IAAA,MAAM,EAAE,QAAA,EAAU,QAAU,EAAA,KAAA,EAAO,QAAW,GAAA,OAAA;AAE9C,IAAA,MAAM,EAAE,MAAA,EAAQ,aAAe,EAAA,IAAA,KAAS,MAAkB,EAAA;AAC1D,IAAA,MAAM,MAAM,MAAO,EAAA;AACnB,IAAA,MAAM,EAAE,UAAA,EAAY,OAAS,EAAA,QAAA,KAAa,mBAAoB,EAAA;AAC9D,IAAA,MAAM,gBAAgB,gBAAiB,EAAA;AAEvC,IAAM,MAAA,IAAA,GAAO,QAAQ,SAAS,CAAA;AAC9B,IAAM,MAAA,OAAA,GAAU,WAAW,SAAS,CAAA;AACpC,IAAM,MAAA,eAAA,GAAkB,IAAI,eAAA,CAAgB,OAAS,EAAA;AAAA,MACnD,GAAA;AAAA,MACA,MAAA;AAAA,MACA,aAAA;AAAA,MACA,IAAA;AAAA,MACA,UAAU,OAAQ,CAAA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W,IAAM,EAAA,kBAAA,CAAmB,WAAW,EAAE,IAAA,EAAM,UAAW,EAAC,GAAI,CAAA,CAAA;AAEtI,IAAA,MAAM,OAAU,GAAA,MAAA,CAAO,OAAQ,CAAA,qBAAqB,CACjD,CAAA,GAAA,CAAI,CAAC,CAAC,GAAK,EAAA,EAAE,IAAM,EAAA,SAAA,EAAW,CAAM,KAAA;AACnC,MAAA,MAAM,QAAQ,CAAC,IAAA,CAAK,SAAS,GAAG,MAAA,CAAO,OAAO,IAAK,CAAA,SAAS,CAAG,EAAA,GAAG,OAAO,MAAO,CAAA,IAAA,CAAK,UAAU,CAAC,CAAA,CAAE,OAAO,OAAO,CAAA;AAEhH,MAAA,uBAAOC,GAAAA,CAACC,IAAK,CAAA,MAAA,EAAL,EAAsB,IAAM,EAAA,KAAA,EAAO,IAAM,EAAA,IAAA,CAAK,MAAM,IAAM,EAAA,OAAA,CAAQ,SAAS,CAAA,CAAE,QAA5D,GAAkE,CAAA;AAAA,KAC5F,CACA,CAAA,MAAA,CAAO,OAAO,CAAA;AAEjB,IACE,uBAAAC,IAACD,CAAAA,IAAAA,EAAA,EAAK,QAAA,EAAU,IAAK,CAAA,QAAA,EAAU,IAAM,EAAA,IAAA,CAAK,IAAM,EAAA,IAAA,EAAM,IAAK,CAAA,IAAA,EAAM,QAAQE,SAAU,CAAA,EAAE,GAAK,EAAA,MAAA,EAAQ,CAAA,EAAG,MAAQC,EAAAA,SAAAA,CAAU,EAAE,GAAA,EAAK,MAAO,EAAC,CACnI,EAAA,QAAA,EAAA;AAAA,MAAA,OAAA;AAAA,sBACDJ,GAAAA,CAAC,UAAW,EAAA,EAAA,IAAA,EAAY,YAAY,qBAAuB,EAAA;AAAA,KAC7D,EAAA,CAAA;AAAA;AAGN,CAAC","file":"chunk-LBZ6BUKN.js","sourcesContent":["import { type OperationSchema as OperationSchemaType, SchemaGenerator, createReactGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, useApp } from '@kubb/react'\nimport { Zod } from '../components'\nimport type { PluginZod } from '../types'\n\nexport const zodGenerator = createReactGenerator<PluginZod>({\n name: 'zod',\n Operation({ operation, options }) {\n const { coercion, inferred, typed, mapper } = options\n\n const { plugin, pluginManager, mode } = useApp<PluginZod>()\n const oas = useOas()\n const { getSchemas, getFile, getGroup } = useOperationManager()\n const schemaManager = useSchemaManager()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const schemaGenerator = new SchemaGenerator(options, {\n oas,\n plugin,\n pluginManager,\n mode,\n override: options.override,\n })\n\n const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response]\n .flat()\n .filter(Boolean)\n\n const mapOperationSchema = ({ name, schema, description, keysToOmit, ...options }: OperationSchemaType, i: number) => {\n // hack so Params can be optional when needed\n const required = Array.isArray(schema?.required) ? !!schema.required.length : !!schema?.required\n const optional = !required && name.includes('Params')\n const tree = [...schemaGenerator.parse({ schema, name }), optional ? { keyword: schemaKeywords.optional } : undefined].filter(Boolean)\n const imports = schemaManager.getImports(tree)\n const group = options.operation ? getGroup(options.operation) : undefined\n\n const zod = {\n name: schemaManager.getName(name, { type: 'function' }),\n inferTypeName: schemaManager.getName(name, { type: 'type' }),\n file: schemaManager.getFile(name),\n }\n\n const type = {\n name: schemaManager.getName(name, { type: 'type', pluginKey: [pluginTsName] }),\n file: schemaManager.getFile(options.operationName || name, { pluginKey: [pluginTsName], group }),\n }\n\n return (\n <Oas.Schema key={i} name={name} value={schema} tree={tree}>\n {typed && <File.Import isTypeOnly root={file.path} path={type.file.path} name={[type.name]} />}\n {typed && <File.Import isTypeOnly path={'@kubb/plugin-zod/utils'} name={['ToZod']} />}\n {imports.map((imp, index) => (\n <File.Import key={index} root={file.path} path={imp.path} name={imp.name} />\n ))}\n <Zod\n name={zod.name}\n typeName={typed ? type.name : undefined}\n inferTypeName={inferred ? zod.inferTypeName : undefined}\n description={description}\n tree={tree}\n mapper={mapper}\n coercion={coercion}\n keysToOmit={keysToOmit}\n />\n </Oas.Schema>\n )\n }\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: plugin.options.output })}\n footer={getFooter({ oas, output: plugin.options.output })}\n >\n <File.Import name={['z']} path={plugin.options.importPath} />\n {operationSchemas.map(mapOperationSchema)}\n </File>\n )\n },\n Schema({ schema, options }) {\n const { coercion, inferred, typed, mapper, importPath } = options\n\n const { getName, getFile, getImports } = useSchemaManager()\n const {\n plugin: {\n options: { output },\n },\n } = useApp<PluginZod>()\n const oas = useOas()\n\n const imports = getImports(schema.tree)\n\n const zod = {\n name: getName(schema.name, { type: 'function' }),\n inferTypeName: getName(schema.name, { type: 'type' }),\n file: getFile(schema.name),\n }\n\n const type = {\n name: getName(schema.name, { type: 'type', pluginKey: [pluginTsName] }),\n file: getFile(schema.name, { pluginKey: [pluginTsName] }),\n }\n\n return (\n <File baseName={zod.file.baseName} path={zod.file.path} meta={zod.file.meta} banner={getBanner({ oas, output })} footer={getFooter({ oas, output })}>\n <File.Import name={['z']} path={importPath} />\n {typed && <File.Import isTypeOnly root={zod.file.path} path={type.file.path} name={[type.name]} />}\n {typed && <File.Import isTypeOnly path={'@kubb/plugin-zod/utils'} name={['ToZod']} />}\n {imports.map((imp, index) => (\n <File.Import key={index} root={zod.file.path} path={imp.path} name={imp.name} />\n ))}\n\n <Zod\n name={zod.name}\n typeName={typed ? type.name : undefined}\n inferTypeName={inferred ? zod.inferTypeName : undefined}\n description={schema.value.description}\n tree={schema.tree}\n mapper={mapper}\n coercion={coercion}\n />\n </File>\n )\n },\n})\n","import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, useApp } from '@kubb/react'\nimport { Operations } from '../components/Operations'\nimport type { PluginZod } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginZod>({\n name: 'operations',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { output },\n },\n } = useApp<PluginZod>()\n const oas = useOas()\n const { getFile, groupSchemasByName } = useOperationManager()\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey })\n\n const transformedOperations = operations.map((operation) => ({ operation, data: groupSchemasByName(operation, { type: 'function' }) }))\n\n const imports = Object.entries(transformedOperations)\n .map(([key, { data, operation }]) => {\n const names = [data.request, ...Object.values(data.responses), ...Object.values(data.parameters)].filter(Boolean)\n\n return <File.Import key={key} name={names} root={file.path} path={getFile(operation).path} />\n })\n .filter(Boolean)\n\n return (\n <File baseName={file.baseName} path={file.path} meta={file.meta} banner={getBanner({ oas, output })} footer={getFooter({ oas, output })}>\n {imports}\n <Operations name={name} operations={transformedOperations} />\n </File>\n )\n },\n})\n"]}
|
package/dist/components.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkE2BLKQJO_cjs = require('./chunk-E2BLKQJO.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 chunkE2BLKQJO_cjs.Operations; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "Zod", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkE2BLKQJO_cjs.Zod; }
|
|
14
14
|
});
|
|
15
15
|
//# sourceMappingURL=components.cjs.map
|
|
16
16
|
//# sourceMappingURL=components.cjs.map
|
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/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 chunk6N5S7RR7_cjs = require('./chunk-6N5S7RR7.cjs');
|
|
4
|
+
require('./chunk-E2BLKQJO.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 chunk6N5S7RR7_cjs.operationsGenerator; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "zodGenerator", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunk6N5S7RR7_cjs.zodGenerator; }
|
|
15
15
|
});
|
|
16
16
|
//# sourceMappingURL=generators.cjs.map
|
|
17
17
|
//# sourceMappingURL=generators.cjs.map
|
package/dist/generators.d.cts
CHANGED
package/dist/generators.d.ts
CHANGED
package/dist/generators.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { operationsGenerator, zodGenerator } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { operationsGenerator, zodGenerator } from './chunk-LBZ6BUKN.js';
|
|
2
|
+
import './chunk-CPI4DGDT.js';
|
|
3
3
|
//# sourceMappingURL=generators.js.map
|
|
4
4
|
//# sourceMappingURL=generators.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunk6N5S7RR7_cjs = require('./chunk-6N5S7RR7.cjs');
|
|
4
|
+
require('./chunk-E2BLKQJO.cjs');
|
|
5
5
|
var path = require('path');
|
|
6
6
|
var core = require('@kubb/core');
|
|
7
7
|
var transformers = require('@kubb/core/transformers');
|
|
@@ -29,7 +29,8 @@ var pluginZod = core.createPlugin((options) => {
|
|
|
29
29
|
importPath = "zod",
|
|
30
30
|
coercion = false,
|
|
31
31
|
inferred = false,
|
|
32
|
-
generators = [
|
|
32
|
+
generators = [chunk6N5S7RR7_cjs.zodGenerator, operations ? chunk6N5S7RR7_cjs.operationsGenerator : undefined].filter(Boolean),
|
|
33
|
+
contentType
|
|
33
34
|
} = options;
|
|
34
35
|
return {
|
|
35
36
|
name: pluginZodName,
|
|
@@ -49,7 +50,7 @@ var pluginZod = core.createPlugin((options) => {
|
|
|
49
50
|
inferred,
|
|
50
51
|
group
|
|
51
52
|
},
|
|
52
|
-
pre: [pluginOas.pluginOasName, typed ? pluginTs.pluginTsName :
|
|
53
|
+
pre: [pluginOas.pluginOasName, typed ? pluginTs.pluginTsName : undefined].filter(Boolean),
|
|
53
54
|
resolvePath(baseName, pathMode, options2) {
|
|
54
55
|
const root = path__default.default.resolve(this.config.root, this.config.output.path);
|
|
55
56
|
const mode = pathMode ?? core.FileManager.getMode(path__default.default.resolve(root, output.path));
|
|
@@ -76,7 +77,7 @@ var pluginZod = core.createPlugin((options) => {
|
|
|
76
77
|
},
|
|
77
78
|
resolveName(name, type) {
|
|
78
79
|
let resolvedName = transformers.camelCase(name, {
|
|
79
|
-
suffix: type ? "schema" :
|
|
80
|
+
suffix: type ? "schema" : undefined,
|
|
80
81
|
isFile: type === "file"
|
|
81
82
|
});
|
|
82
83
|
if (type === "type") {
|
|
@@ -96,8 +97,8 @@ var pluginZod = core.createPlugin((options) => {
|
|
|
96
97
|
oas,
|
|
97
98
|
pluginManager: this.pluginManager,
|
|
98
99
|
plugin: this.plugin,
|
|
99
|
-
contentType
|
|
100
|
-
include:
|
|
100
|
+
contentType,
|
|
101
|
+
include: undefined,
|
|
101
102
|
override,
|
|
102
103
|
mode,
|
|
103
104
|
output: output.path
|
|
@@ -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,
|
|
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,OAAA;AAAA,MACA,OAAA;AAAA,MACA,QAAA;AAAA,MACA,KAAA;AAAA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ager, 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
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { zodGenerator, operationsGenerator } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
import { zodGenerator, operationsGenerator } from './chunk-LBZ6BUKN.js';
|
|
2
|
+
import './chunk-CPI4DGDT.js';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { createPlugin, FileManager, PluginManager } from '@kubb/core';
|
|
5
5
|
import { camelCase, pascalCase } from '@kubb/core/transformers';
|
|
@@ -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 :
|
|
26
|
+
generators = [zodGenerator, operations ? operationsGenerator : undefined].filter(Boolean),
|
|
27
|
+
contentType
|
|
27
28
|
} = options;
|
|
28
29
|
return {
|
|
29
30
|
name: pluginZodName,
|
|
@@ -43,7 +44,7 @@ var pluginZod = createPlugin((options) => {
|
|
|
43
44
|
inferred,
|
|
44
45
|
group
|
|
45
46
|
},
|
|
46
|
-
pre: [pluginOasName, typed ? pluginTsName :
|
|
47
|
+
pre: [pluginOasName, typed ? pluginTsName : undefined].filter(Boolean),
|
|
47
48
|
resolvePath(baseName, pathMode, options2) {
|
|
48
49
|
const root = path.resolve(this.config.root, this.config.output.path);
|
|
49
50
|
const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path));
|
|
@@ -70,7 +71,7 @@ var pluginZod = createPlugin((options) => {
|
|
|
70
71
|
},
|
|
71
72
|
resolveName(name, type) {
|
|
72
73
|
let resolvedName = camelCase(name, {
|
|
73
|
-
suffix: type ? "schema" :
|
|
74
|
+
suffix: type ? "schema" : undefined,
|
|
74
75
|
isFile: type === "file"
|
|
75
76
|
});
|
|
76
77
|
if (type === "type") {
|
|
@@ -90,8 +91,8 @@ var pluginZod = createPlugin((options) => {
|
|
|
90
91
|
oas,
|
|
91
92
|
pluginManager: this.pluginManager,
|
|
92
93
|
plugin: this.plugin,
|
|
93
|
-
contentType
|
|
94
|
-
include:
|
|
94
|
+
contentType,
|
|
95
|
+
include: undefined,
|
|
95
96
|
override,
|
|
96
97
|
mode,
|
|
97
98
|
output: output.path
|
|
@@ -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,
|
|
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,G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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
|
-
"tsup": "^8.3.
|
|
78
|
+
"tsup": "^8.3.6",
|
|
79
79
|
"zod": "~3.24.1",
|
|
80
|
-
"@kubb/config-ts": "3.5.
|
|
81
|
-
"@kubb/config-tsup": "3.5.
|
|
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/components/Zod.tsx
CHANGED
|
@@ -2,7 +2,6 @@ import transformers from '@kubb/core/transformers'
|
|
|
2
2
|
import { type Schema, schemaKeywords } from '@kubb/plugin-oas'
|
|
3
3
|
import { isKeyword } from '@kubb/plugin-oas'
|
|
4
4
|
import { Const, File, Type } from '@kubb/react'
|
|
5
|
-
import type { KubbNode } from '@kubb/react/types'
|
|
6
5
|
import * as parserZod from '../parser.ts'
|
|
7
6
|
import type { PluginZod } from '../types.ts'
|
|
8
7
|
|
package/src/parser.ts
CHANGED
|
@@ -292,7 +292,7 @@ export function parse({ parent, current, siblings }: SchemaTree, options: Parser
|
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
return `"${name}": ${sort(schemas)
|
|
295
|
-
.map((schema
|
|
295
|
+
.map((schema) => parse({ parent: current, current: schema, siblings: schemas }, options))
|
|
296
296
|
.filter(Boolean)
|
|
297
297
|
.join('')}`
|
|
298
298
|
})
|
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
|
*/
|