@kubb/plugin-zod 4.0.0 → 4.0.2
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-Bv7MaVo7.cjs → components-DQw9romi.cjs} +72 -34
- package/dist/components-DQw9romi.cjs.map +1 -0
- package/dist/{components-DtKP6doO.js → components-GBbHstRa.js} +72 -34
- package/dist/components-GBbHstRa.js.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/{generators-BY96mD4w.js → generators-C6LY9NRE.js} +2 -2
- package/dist/{generators-BY96mD4w.js.map → generators-C6LY9NRE.js.map} +1 -1
- package/dist/{generators-CrSYV5kr.cjs → generators-CfwuO_nS.cjs} +2 -2
- package/dist/{generators-CrSYV5kr.cjs.map → generators-CfwuO_nS.cjs.map} +1 -1
- package/dist/generators.cjs +2 -2
- package/dist/generators.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/package.json +8 -9
- package/src/components/Zod.tsx +7 -5
- package/src/generators/__snapshots__/coercion.ts +5 -8
- package/src/generators/__snapshots__/coercionDates.ts +5 -8
- package/src/generators/__snapshots__/coercionNumbers.ts +5 -8
- package/src/generators/__snapshots__/coercionStrings.ts +5 -8
- package/src/generators/__snapshots__/deletePet.ts +1 -1
- package/src/generators/__snapshots__/deletePet_wrapOutput.ts +1 -1
- package/src/generators/__snapshots__/example.ts +1 -1
- package/src/generators/__snapshots__/getPets.ts +2 -2
- package/src/generators/__snapshots__/getPets_wrapOutput.ts +2 -2
- package/src/generators/__snapshots__/nullable.ts +1 -1
- package/src/generators/__snapshots__/oneof.ts +2 -2
- package/src/generators/__snapshots__/optionalPetInfer.ts +3 -3
- package/src/generators/__snapshots__/optionalPetTyped.ts +3 -3
- package/src/generators/__snapshots__/order.ts +6 -6
- package/src/generators/__snapshots__/orderDateTypeFalse.ts +6 -6
- package/src/generators/__snapshots__/orderDateTypeString.ts +6 -6
- package/src/generators/__snapshots__/pet.ts +5 -8
- package/src/generators/__snapshots__/petCoercion.ts +5 -8
- package/src/generators/__snapshots__/petTupleObject.ts +1 -1
- package/src/generators/__snapshots__/petV4.ts +5 -8
- package/src/generators/__snapshots__/petWithMapper.ts +5 -8
- package/src/generators/__snapshots__/pets.ts +1 -1
- package/src/generators/__snapshots__/queryAllDefaulted.ts +2 -2
- package/src/generators/__snapshots__/queryAllDefaulted_wrapOutput.ts +2 -2
- package/src/generators/__snapshots__/toy.ts +2 -2
- package/src/parser.ts +78 -21
- package/dist/components-Bv7MaVo7.cjs.map +0 -1
- package/dist/components-DtKP6doO.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generators-CrSYV5kr.cjs","names":["SchemaGenerator","options","schemaKeywords","pluginTsName","Oas","File","Zod","File","Operations"],"sources":["../src/generators/zodGenerator.tsx","../src/generators/operationsGenerator.tsx"],"sourcesContent":["import { createReactGenerator, type OperationSchema as OperationSchemaType, SchemaGenerator, 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: globalCoercion, inferred, typed, mapper, wrapOutput } = 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: schemaObject, description, keysToOmit, ...options }: OperationSchemaType, i: number) => {\n // hack so Params can be optional when needed\n const required = Array.isArray(schemaObject?.required) ? !!schemaObject.required.length : !!schemaObject?.required\n const someDefaults = Object.values(schemaObject.properties || {}).some((property) => Object.hasOwn(property, 'default') && property.default !== undefined)\n const optional = !required && !someDefaults && name.includes('Params')\n\n const tree = [...schemaGenerator.parse({ schemaObject, 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 coercion = name.includes('Params') ? { numbers: true, strings: false, dates: true } : globalCoercion\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, {\n type: 'type',\n pluginKey: [pluginTsName],\n }),\n file: schemaManager.getFile(options.operationName || name, {\n pluginKey: [pluginTsName],\n group,\n }),\n }\n\n return (\n <Oas.Schema key={i} name={name} schemaObject={schemaObject} tree={tree}>\n {typed && <File.Import isTypeOnly root={file.path} path={type.file.path} name={[type.name]} />}\n {typed && <File.Import isTypeOnly path={plugin.options.version === '4' ? '@kubb/plugin-zod/utils/v4' : '@kubb/plugin-zod/utils'} name={['ToZod']} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} 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 rawSchema={schemaObject}\n mapper={mapper}\n coercion={coercion}\n keysToOmit={keysToOmit}\n wrapOutput={wrapOutput}\n version={plugin.options.version}\n emptySchemaType={plugin.options.emptySchemaType}\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, config: pluginManager.config })}\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, wrapOutput, version } = options\n\n const { getName, getFile, getImports } = useSchemaManager()\n const {\n pluginManager,\n plugin: {\n options: { output, emptySchemaType },\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\n baseName={zod.file.baseName}\n path={zod.file.path}\n meta={zod.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\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={options.version === '4' ? '@kubb/plugin-zod/utils/v4' : '@kubb/plugin-zod/utils'} name={['ToZod']} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} 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 rawSchema={schema.value}\n mapper={mapper}\n coercion={coercion}\n wrapOutput={wrapOutput}\n version={version}\n emptySchemaType={emptySchemaType}\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\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {imports}\n <Operations name={name} operations={transformedOperations} />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;AASA,MAAa,2DAA+C;CAC1D,MAAM;CACN,UAAU,EAAE,WAAW,WAAW;EAChC,MAAM,EAAE,UAAU,gBAAgB,UAAU,OAAO,QAAQ,eAAe;EAE1E,MAAM,EAAE,QAAQ,eAAe,mCAA4B;EAC3D,MAAM,2CAAc;EACpB,MAAM,EAAE,YAAY,SAAS,+DAAkC;EAC/D,MAAM,+DAAkC;EAExC,MAAM,OAAO,QAAQ,UAAU;EAC/B,MAAM,UAAU,WAAW,UAAU;EACrC,MAAM,kBAAkB,IAAIA,kCAAgB,SAAS;GACnD;GACA;GACA;GACA;GACA,UAAU,QAAQ;GACnB,CAAC;EAEF,MAAM,mBAAmB;GAAC,QAAQ;GAAY,QAAQ;GAAa,QAAQ;GAAc,QAAQ;GAAa,QAAQ;GAAS,QAAQ;GAAS,CAC7I,MAAM,CACN,OAAO,QAAQ;EAElB,MAAM,sBAAs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;GAAM,SAAS;GAAO;GAAW,CAAC;EAEvE,MAAM,wBAAwB,WAAW,KAAK,eAAe;GAAE;GAAW,MAAM,mBAAmB,WAAW,EAAE,MAAM,YAAY,CAAC;GAAE,EAAE;EAEvI,MAAM,UAAU,OAAO,QAAQ,sBAAsB,CAClD,KAAK,CAAC,KAAK,EAAE,MAAM,iBAAiB;GACnC,MAAM,QAAQ;IAAC,KAAK;IAAS,GAAG,OAAO,OAAO,KAAK,UAAU;IAAE,GAAG,OAAO,OAAO,KAAK,WAAW;IAAC,CAAC,OAAO,QAAQ;AAEjH,UAAO,kDAACC,kBAAK;IAAiB,MAAM;IAAO,MAAM,KAAK;IAAM,MAAM,QAAQ,UAAU,CAAC;MAA5D,IAAoE;IAC7F,CACD,OAAO,QAAQ;AAElB,SACE,mDAACA;GACC,UAAU,KAAK;GACf,MAAM,KAAK;GACX,MAAM,KAAK;GACX,+CAAkB;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChE,+CAAkB;IAAE;IAAK;IAAQ,CAAC;cAEjC,SACD,kDAACC;IAAiB;IAAM,YAAY;KAAyB;IACxD;;CAGZ,CAAC"}
|
|
1
|
+
{"version":3,"file":"generators-CfwuO_nS.cjs","names":["SchemaGenerator","options","schemaKeywords","pluginTsName","Oas","File","Zod","File","Operations"],"sources":["../src/generators/zodGenerator.tsx","../src/generators/operationsGenerator.tsx"],"sourcesContent":["import { createReactGenerator, type OperationSchema as OperationSchemaType, SchemaGenerator, 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: globalCoercion, inferred, typed, mapper, wrapOutput } = 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: schemaObject, description, keysToOmit, ...options }: OperationSchemaType, i: number) => {\n // hack so Params can be optional when needed\n const required = Array.isArray(schemaObject?.required) ? !!schemaObject.required.length : !!schemaObject?.required\n const someDefaults = Object.values(schemaObject.properties || {}).some((property) => Object.hasOwn(property, 'default') && property.default !== undefined)\n const optional = !required && !someDefaults && name.includes('Params')\n\n const tree = [...schemaGenerator.parse({ schemaObject, 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 coercion = name.includes('Params') ? { numbers: true, strings: false, dates: true } : globalCoercion\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, {\n type: 'type',\n pluginKey: [pluginTsName],\n }),\n file: schemaManager.getFile(options.operationName || name, {\n pluginKey: [pluginTsName],\n group,\n }),\n }\n\n return (\n <Oas.Schema key={i} name={name} schemaObject={schemaObject} tree={tree}>\n {typed && <File.Import isTypeOnly root={file.path} path={type.file.path} name={[type.name]} />}\n {typed && <File.Import isTypeOnly path={plugin.options.version === '4' ? '@kubb/plugin-zod/utils/v4' : '@kubb/plugin-zod/utils'} name={['ToZod']} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} 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 rawSchema={schemaObject}\n mapper={mapper}\n coercion={coercion}\n keysToOmit={keysToOmit}\n wrapOutput={wrapOutput}\n version={plugin.options.version}\n emptySchemaType={plugin.options.emptySchemaType}\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, config: pluginManager.config })}\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, wrapOutput, version } = options\n\n const { getName, getFile, getImports } = useSchemaManager()\n const {\n pluginManager,\n plugin: {\n options: { output, emptySchemaType },\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\n baseName={zod.file.baseName}\n path={zod.file.path}\n meta={zod.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\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={options.version === '4' ? '@kubb/plugin-zod/utils/v4' : '@kubb/plugin-zod/utils'} name={['ToZod']} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} 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 rawSchema={schema.value}\n mapper={mapper}\n coercion={coercion}\n wrapOutput={wrapOutput}\n version={version}\n emptySchemaType={emptySchemaType}\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\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {imports}\n <Operations name={name} operations={transformedOperations} />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;AASA,MAAa,2DAA+C;CAC1D,MAAM;CACN,UAAU,EAAE,WAAW,WAAW;EAChC,MAAM,EAAE,UAAU,gBAAgB,UAAU,OAAO,QAAQ,eAAe;EAE1E,MAAM,EAAE,QAAQ,eAAe,mCAA4B;EAC3D,MAAM,2CAAc;EACpB,MAAM,EAAE,YAAY,SAAS,+DAAkC;EAC/D,MAAM,+DAA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,MAAM,OAAO;KACb,WAAW,OAAO;KACV;KACE;KACE;KACH;KACQ;MACjB;;IACG;;CAGZ,CAAC;;;;ACrJF,MAAa,kEAAsD;CACjE,MAAM;CACN,WAAW,EAAE,cAAc;EACzB,MAAM,EACJ,eACA,QAAQ,EACN,KAAK,WACL,SAAS,EAAE,yCAEQ;EACvB,MAAM,2CAAc;EACpB,MAAM,EAAE,SAAS,yEAA4C;EAE7D,MAAM,OAAO;EACb,MAAM,OAAO,cAAc,QAAQ;GAAE;GAAM,SAAS;GAAO;GAAW,CAAC;EAEvE,MAAM,wBAAwB,WAAW,KAAK,eAAe;GAAE;GAAW,MAAM,mBAAmB,WAAW,EAAE,MAAM,YAAY,CAAC;GAAE,EAAE;EAEvI,MAAM,UAAU,OAAO,QAAQ,sBAAsB,CAClD,KAAK,CAAC,KAAK,EAAE,MAAM,iBAAiB;GACnC,MAAM,QAAQ;IAAC,KAAK;IAAS,GAAG,OAAO,OAAO,KAAK,UAAU;IAAE,GAAG,OAAO,OAAO,KAAK,WAAW;IAAC,CAAC,OAAO,QAAQ;AAEjH,UAAO,kDAACC,kBAAK;IAAiB,MAAM;IAAO,MAAM,KAAK;IAAM,MAAM,QAAQ,UAAU,CAAC;MAA5D,IAAoE;IAC7F,CACD,OAAO,QAAQ;AAElB,SACE,mDAACA;GACC,UAAU,KAAK;GACf,MAAM,KAAK;GACX,MAAM,KAAK;GACX,+CAAkB;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChE,+CAAkB;IAAE;IAAK;IAAQ,CAAC;cAEjC,SACD,kDAACC;IAAiB;IAAM,YAAY;KAAyB;IACxD;;CAGZ,CAAC"}
|
package/dist/generators.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
require('./components-
|
|
2
|
-
const require_generators = require('./generators-
|
|
1
|
+
require('./components-DQw9romi.cjs');
|
|
2
|
+
const require_generators = require('./generators-CfwuO_nS.cjs');
|
|
3
3
|
|
|
4
4
|
exports.operationsGenerator = require_generators.operationsGenerator;
|
|
5
5
|
exports.zodGenerator = require_generators.zodGenerator;
|
package/dist/generators.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./components-
|
|
2
|
-
import { operationsGenerator, zodGenerator } from "./generators-
|
|
1
|
+
import "./components-GBbHstRa.js";
|
|
2
|
+
import { operationsGenerator, zodGenerator } from "./generators-C6LY9NRE.js";
|
|
3
3
|
|
|
4
4
|
export { operationsGenerator, zodGenerator };
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_components = require('./components-
|
|
2
|
-
const require_generators = require('./generators-
|
|
1
|
+
const require_components = require('./components-DQw9romi.cjs');
|
|
2
|
+
const require_generators = require('./generators-CfwuO_nS.cjs');
|
|
3
3
|
let node_path = require("node:path");
|
|
4
4
|
node_path = require_components.__toESM(node_path);
|
|
5
5
|
let __kubb_core = require("@kubb/core");
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./components-
|
|
2
|
-
import { operationsGenerator, zodGenerator } from "./generators-
|
|
1
|
+
import "./components-GBbHstRa.js";
|
|
2
|
+
import { operationsGenerator, zodGenerator } from "./generators-C6LY9NRE.js";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { FileManager, PackageManager, PluginManager, createPlugin } from "@kubb/core";
|
|
5
5
|
import { camelCase, pascalCase } from "@kubb/core/transformers";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-zod",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Zod schema generator plugin for Kubb, creating type-safe validation schemas from OpenAPI specifications for runtime data validation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"zod",
|
|
@@ -73,20 +73,19 @@
|
|
|
73
73
|
"!/**/__tests__/**"
|
|
74
74
|
],
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@kubb/core": "4.0.
|
|
77
|
-
"@kubb/oas": "4.0.
|
|
78
|
-
"@kubb/parser-ts": "4.0.
|
|
79
|
-
"@kubb/plugin-oas": "4.0.
|
|
80
|
-
"@kubb/
|
|
81
|
-
"@kubb/
|
|
76
|
+
"@kubb/core": "4.0.2",
|
|
77
|
+
"@kubb/oas": "4.0.2",
|
|
78
|
+
"@kubb/parser-ts": "4.0.2",
|
|
79
|
+
"@kubb/plugin-oas": "4.0.2",
|
|
80
|
+
"@kubb/react": "4.0.2",
|
|
81
|
+
"@kubb/plugin-ts": "4.0.2"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
84
|
"@asteasolutions/zod-to-openapi": "^7.3.4",
|
|
85
85
|
"@hono/zod-openapi": "0.19.2",
|
|
86
86
|
"tsdown": "^0.14.2",
|
|
87
87
|
"zod": "^3.25.76",
|
|
88
|
-
"@kubb/
|
|
89
|
-
"@kubb/plugin-oas": "4.0.0"
|
|
88
|
+
"@kubb/plugin-oas": "4.0.2"
|
|
90
89
|
},
|
|
91
90
|
"peerDependencies": {
|
|
92
91
|
"@kubb/react": "^4.0.0"
|
package/src/components/Zod.tsx
CHANGED
|
@@ -45,12 +45,14 @@ export function Zod({
|
|
|
45
45
|
})
|
|
46
46
|
|
|
47
47
|
const output = schemas
|
|
48
|
-
.map((schema,
|
|
49
|
-
|
|
48
|
+
.map((schema, index) => {
|
|
49
|
+
const siblings = schemas.filter((_, i) => i !== index)
|
|
50
|
+
|
|
51
|
+
return parserZod.parse(
|
|
50
52
|
{ parent: undefined, current: schema, siblings },
|
|
51
53
|
{ name, keysToOmit, typeName, description, mapper, coercion, wrapOutput, rawSchema, version },
|
|
52
|
-
)
|
|
53
|
-
)
|
|
54
|
+
)
|
|
55
|
+
})
|
|
54
56
|
.filter(Boolean)
|
|
55
57
|
.join('')
|
|
56
58
|
|
|
@@ -86,7 +88,7 @@ export function Zod({
|
|
|
86
88
|
)
|
|
87
89
|
|
|
88
90
|
const baseSchemaOutput =
|
|
89
|
-
[output, keysToOmit?.length ? `${suffix}.omit({ ${keysToOmit.map((key) =>
|
|
91
|
+
[output, keysToOmit?.length ? `${suffix}.omit({ ${keysToOmit.map((key) => `'${key}': true`).join(',')} })` : undefined].filter(Boolean).join('') ||
|
|
90
92
|
emptyValue ||
|
|
91
93
|
''
|
|
92
94
|
const wrappedSchemaOutput = wrapOutput ? wrapOutput({ output: baseSchemaOutput, schema: rawSchema }) || baseSchemaOutput : baseSchemaOutput
|
|
@@ -7,12 +7,9 @@ import { z } from 'zod'
|
|
|
7
7
|
export const pet = z.object({
|
|
8
8
|
id: z.coerce.number().int(),
|
|
9
9
|
name: z.coerce.string(),
|
|
10
|
-
date: z.coerce.date()
|
|
11
|
-
uuid: z.coerce.string().uuid()
|
|
12
|
-
email: z.coerce.string().email()
|
|
13
|
-
pattern: z.coerce
|
|
14
|
-
|
|
15
|
-
.regex(/^[a-zA-Z0-9]{3}$/)
|
|
16
|
-
.optional(),
|
|
17
|
-
tag: z.coerce.string().min(5).max(100).optional(),
|
|
10
|
+
date: z.optional(z.coerce.date()),
|
|
11
|
+
uuid: z.optional(z.coerce.string().uuid()),
|
|
12
|
+
email: z.optional(z.coerce.string().email()),
|
|
13
|
+
pattern: z.optional(z.coerce.string().regex(/^[a-zA-Z0-9]{3}$/)),
|
|
14
|
+
tag: z.optional(z.coerce.string().min(5).max(100)),
|
|
18
15
|
})
|
|
@@ -7,12 +7,9 @@ import { z } from 'zod'
|
|
|
7
7
|
export const pet = z.object({
|
|
8
8
|
id: z.number().int(),
|
|
9
9
|
name: z.string(),
|
|
10
|
-
date: z.coerce.date()
|
|
11
|
-
uuid: z.string().uuid()
|
|
12
|
-
email: z.string().email()
|
|
13
|
-
pattern: z
|
|
14
|
-
|
|
15
|
-
.regex(/^[a-zA-Z0-9]{3}$/)
|
|
16
|
-
.optional(),
|
|
17
|
-
tag: z.string().min(5).max(100).optional(),
|
|
10
|
+
date: z.optional(z.coerce.date()),
|
|
11
|
+
uuid: z.optional(z.string().uuid()),
|
|
12
|
+
email: z.optional(z.string().email()),
|
|
13
|
+
pattern: z.optional(z.string().regex(/^[a-zA-Z0-9]{3}$/)),
|
|
14
|
+
tag: z.optional(z.string().min(5).max(100)),
|
|
18
15
|
})
|
|
@@ -7,12 +7,9 @@ import { z } from 'zod'
|
|
|
7
7
|
export const pet = z.object({
|
|
8
8
|
id: z.coerce.number().int(),
|
|
9
9
|
name: z.string(),
|
|
10
|
-
date: z.
|
|
11
|
-
uuid: z.string().uuid()
|
|
12
|
-
email: z.string().email()
|
|
13
|
-
pattern: z
|
|
14
|
-
|
|
15
|
-
.regex(/^[a-zA-Z0-9]{3}$/)
|
|
16
|
-
.optional(),
|
|
17
|
-
tag: z.string().min(5).max(100).optional(),
|
|
10
|
+
date: z.optional(z.date()),
|
|
11
|
+
uuid: z.optional(z.string().uuid()),
|
|
12
|
+
email: z.optional(z.string().email()),
|
|
13
|
+
pattern: z.optional(z.string().regex(/^[a-zA-Z0-9]{3}$/)),
|
|
14
|
+
tag: z.optional(z.string().min(5).max(100)),
|
|
18
15
|
})
|
|
@@ -7,12 +7,9 @@ import { z } from 'zod'
|
|
|
7
7
|
export const pet = z.object({
|
|
8
8
|
id: z.number().int(),
|
|
9
9
|
name: z.coerce.string(),
|
|
10
|
-
date: z.
|
|
11
|
-
uuid: z.coerce.string().uuid()
|
|
12
|
-
email: z.coerce.string().email()
|
|
13
|
-
pattern: z.coerce
|
|
14
|
-
|
|
15
|
-
.regex(/^[a-zA-Z0-9]{3}$/)
|
|
16
|
-
.optional(),
|
|
17
|
-
tag: z.coerce.string().min(5).max(100).optional(),
|
|
10
|
+
date: z.optional(z.date()),
|
|
11
|
+
uuid: z.optional(z.coerce.string().uuid()),
|
|
12
|
+
email: z.optional(z.coerce.string().email()),
|
|
13
|
+
pattern: z.optional(z.coerce.string().regex(/^[a-zA-Z0-9]{3}$/)),
|
|
14
|
+
tag: z.optional(z.coerce.string().min(5).max(100)),
|
|
18
15
|
})
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { z } from 'zod'
|
|
6
6
|
|
|
7
7
|
export const listPetsQueryParams = z.object({
|
|
8
|
-
limit: z.string().describe('How many items to return at one time (max 100)')
|
|
9
|
-
offset: z.coerce.number().int().default(0),
|
|
8
|
+
limit: z.optional(z.string().describe('How many items to return at one time (max 100)')),
|
|
9
|
+
offset: z.optional(z.coerce.number().int().default(0)),
|
|
10
10
|
})
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { z } from '@hono/zod-openapi'
|
|
6
6
|
|
|
7
7
|
export const listPetsQueryParams = z.object({
|
|
8
|
-
limit: z.string().describe('How many items to return at one time (max 100)')
|
|
9
|
-
offset: z.coerce.number().int().default(0),
|
|
8
|
+
limit: z.optional(z.string().describe('How many items to return at one time (max 100)')),
|
|
9
|
+
offset: z.optional(z.coerce.number().int().default(0)),
|
|
10
10
|
})
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
import { z } from 'zod'
|
|
6
6
|
|
|
7
7
|
export const optionalPet = z.object({
|
|
8
|
-
id: z.number().int()
|
|
9
|
-
name: z.
|
|
10
|
-
tag: z.
|
|
8
|
+
id: z.optional(z.number().int()),
|
|
9
|
+
name: z.optional(z.string()),
|
|
10
|
+
tag: z.optional(z.string()),
|
|
11
11
|
})
|
|
12
12
|
|
|
13
13
|
export type OptionalPet = z.infer<typeof optionalPet>
|
|
@@ -6,7 +6,7 @@ import type { ToZod } from '@kubb/plugin-zod/utils'
|
|
|
6
6
|
import { z } from 'zod'
|
|
7
7
|
|
|
8
8
|
export const optionalPet = z.object({
|
|
9
|
-
id: z.number().int()
|
|
10
|
-
name: z.
|
|
11
|
-
tag: z.
|
|
9
|
+
id: z.optional(z.number().int()),
|
|
10
|
+
name: z.optional(z.string()),
|
|
11
|
+
tag: z.optional(z.string()),
|
|
12
12
|
}) as unknown as ToZod<OptionalPet>
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
import { z } from 'zod'
|
|
6
6
|
|
|
7
7
|
export const order = z.object({
|
|
8
|
-
id: z.number().int()
|
|
9
|
-
petId: z.number().int()
|
|
10
|
-
quantity: z.number().int()
|
|
11
|
-
shipDate: z.
|
|
12
|
-
status: z.enum(['placed', 'approved', 'delivered']).describe('Order Status')
|
|
13
|
-
complete: z.
|
|
8
|
+
id: z.optional(z.number().int()),
|
|
9
|
+
petId: z.optional(z.number().int()),
|
|
10
|
+
quantity: z.optional(z.number().int()),
|
|
11
|
+
shipDate: z.optional(z.date()),
|
|
12
|
+
status: z.optional(z.enum(['placed', 'approved', 'delivered']).describe('Order Status')),
|
|
13
|
+
complete: z.optional(z.boolean()),
|
|
14
14
|
})
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
import { z } from 'zod'
|
|
6
6
|
|
|
7
7
|
export const order = z.object({
|
|
8
|
-
id: z.number().int()
|
|
9
|
-
petId: z.number().int()
|
|
10
|
-
quantity: z.number().int()
|
|
11
|
-
shipDate: z.
|
|
12
|
-
status: z.enum(['placed', 'approved', 'delivered']).describe('Order Status')
|
|
13
|
-
complete: z.
|
|
8
|
+
id: z.optional(z.number().int()),
|
|
9
|
+
petId: z.optional(z.number().int()),
|
|
10
|
+
quantity: z.optional(z.number().int()),
|
|
11
|
+
shipDate: z.optional(z.string()),
|
|
12
|
+
status: z.optional(z.enum(['placed', 'approved', 'delivered']).describe('Order Status')),
|
|
13
|
+
complete: z.optional(z.boolean()),
|
|
14
14
|
})
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
import { z } from 'zod'
|
|
6
6
|
|
|
7
7
|
export const order = z.object({
|
|
8
|
-
id: z.number().int()
|
|
9
|
-
petId: z.number().int()
|
|
10
|
-
quantity: z.number().int()
|
|
11
|
-
shipDate: z.string().datetime()
|
|
12
|
-
status: z.enum(['placed', 'approved', 'delivered']).describe('Order Status')
|
|
13
|
-
complete: z.
|
|
8
|
+
id: z.optional(z.number().int()),
|
|
9
|
+
petId: z.optional(z.number().int()),
|
|
10
|
+
quantity: z.optional(z.number().int()),
|
|
11
|
+
shipDate: z.optional(z.string().datetime()),
|
|
12
|
+
status: z.optional(z.enum(['placed', 'approved', 'delivered']).describe('Order Status')),
|
|
13
|
+
complete: z.optional(z.boolean()),
|
|
14
14
|
})
|
|
@@ -7,12 +7,9 @@ import { z } from 'zod'
|
|
|
7
7
|
export const pet = z.object({
|
|
8
8
|
id: z.number().int(),
|
|
9
9
|
name: z.string(),
|
|
10
|
-
date: z.
|
|
11
|
-
uuid: z.string().uuid()
|
|
12
|
-
email: z.string().email()
|
|
13
|
-
pattern: z
|
|
14
|
-
|
|
15
|
-
.regex(/^[a-zA-Z0-9]{3}$/)
|
|
16
|
-
.optional(),
|
|
17
|
-
tag: z.string().min(5).max(100).optional(),
|
|
10
|
+
date: z.optional(z.date()),
|
|
11
|
+
uuid: z.optional(z.string().uuid()),
|
|
12
|
+
email: z.optional(z.string().email()),
|
|
13
|
+
pattern: z.optional(z.string().regex(/^[a-zA-Z0-9]{3}$/)),
|
|
14
|
+
tag: z.optional(z.string().min(5).max(100)),
|
|
18
15
|
})
|
|
@@ -7,12 +7,9 @@ import { z } from 'zod'
|
|
|
7
7
|
export const pet = z.object({
|
|
8
8
|
id: z.coerce.number().int(),
|
|
9
9
|
name: z.coerce.string(),
|
|
10
|
-
date: z.coerce.date()
|
|
11
|
-
uuid: z.coerce.string().uuid()
|
|
12
|
-
email: z.coerce.string().email()
|
|
13
|
-
pattern: z.coerce
|
|
14
|
-
|
|
15
|
-
.regex(/^[a-zA-Z0-9]{3}$/)
|
|
16
|
-
.optional(),
|
|
17
|
-
tag: z.coerce.string().min(5).max(100).optional(),
|
|
10
|
+
date: z.optional(z.coerce.date()),
|
|
11
|
+
uuid: z.optional(z.coerce.string().uuid()),
|
|
12
|
+
email: z.optional(z.coerce.string().email()),
|
|
13
|
+
pattern: z.optional(z.coerce.string().regex(/^[a-zA-Z0-9]{3}$/)),
|
|
14
|
+
tag: z.optional(z.coerce.string().min(5).max(100)),
|
|
18
15
|
})
|
|
@@ -9,6 +9,6 @@ import { z } from 'zod'
|
|
|
9
9
|
*/
|
|
10
10
|
export const petTupleObject = z
|
|
11
11
|
.object({
|
|
12
|
-
tupleProperty: z.tuple([z.string(), z.string()])
|
|
12
|
+
tupleProperty: z.optional(z.tuple([z.string(), z.string()])),
|
|
13
13
|
})
|
|
14
14
|
.describe('Tuple of exact length 2 nested in an object')
|
|
@@ -7,12 +7,9 @@ import { z } from 'zod'
|
|
|
7
7
|
export const pet = z.object({
|
|
8
8
|
id: z.int(),
|
|
9
9
|
name: z.string(),
|
|
10
|
-
date: z.
|
|
11
|
-
uuid: z.
|
|
12
|
-
email: z.
|
|
13
|
-
pattern: z
|
|
14
|
-
|
|
15
|
-
.regex(/^[a-zA-Z0-9]{3}$/)
|
|
16
|
-
.optional(),
|
|
17
|
-
tag: z.string().min(5).max(100).optional(),
|
|
10
|
+
date: z.optional(z.date()),
|
|
11
|
+
uuid: z.optional(z.uuid()),
|
|
12
|
+
email: z.optional(z.email()),
|
|
13
|
+
pattern: z.optional(z.string().regex(/^[a-zA-Z0-9]{3}$/)),
|
|
14
|
+
tag: z.optional(z.string().min(5).max(100)),
|
|
18
15
|
})
|
|
@@ -7,12 +7,9 @@ import { z } from 'zod'
|
|
|
7
7
|
export const pet = z.object({
|
|
8
8
|
id: z.number().int(),
|
|
9
9
|
name: z.string().email(),
|
|
10
|
-
date: z.
|
|
11
|
-
uuid: z.string().uuid()
|
|
12
|
-
email: z.string().email()
|
|
13
|
-
pattern: z
|
|
14
|
-
|
|
15
|
-
.regex(/^[a-zA-Z0-9]{3}$/)
|
|
16
|
-
.optional(),
|
|
17
|
-
tag: z.string().min(5).max(100).optional(),
|
|
10
|
+
date: z.optional(z.date()),
|
|
11
|
+
uuid: z.optional(z.string().uuid()),
|
|
12
|
+
email: z.optional(z.string().email()),
|
|
13
|
+
pattern: z.optional(z.string().regex(/^[a-zA-Z0-9]{3}$/)),
|
|
14
|
+
tag: z.optional(z.string().min(5).max(100)),
|
|
18
15
|
})
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { z } from 'zod'
|
|
6
6
|
|
|
7
7
|
export const getThingsQueryParams = z.object({
|
|
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'),
|
|
8
|
+
limit: z.optional(z.coerce.number().int().min(1).max(100).default(100).describe('Maximum number of things to return')),
|
|
9
|
+
skip: z.optional(z.coerce.number().int().min(0).default(0).describe('Number of things to skip')),
|
|
10
10
|
})
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
import { z } from '@hono/zod-openapi'
|
|
6
6
|
|
|
7
7
|
export const getThingsQueryParams = z.object({
|
|
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'),
|
|
8
|
+
limit: z.optional(z.coerce.number().int().min(1).max(100).default(100).describe('Maximum number of things to return')),
|
|
9
|
+
skip: z.optional(z.coerce.number().int().min(0).default(0).describe('Number of things to skip')),
|
|
10
10
|
})
|
|
11
11
|
|
|
12
12
|
/**
|