@anatine/zod-openapi
Advanced tools
Comparing version 0.4.0 to 1.0.1
{ | ||
"name": "@anatine/zod-openapi", | ||
"version": "0.4.0", | ||
"version": "1.0.1", | ||
"description": "Zod to OpenAPI converter", | ||
@@ -28,6 +28,6 @@ "main": "src/index.js", | ||
"peerDependencies": { | ||
"zod": "^3.5.1", | ||
"zod": "^3.10.3", | ||
"openapi3-ts": "^2.0.1" | ||
}, | ||
"typings": "./src/index.d.ts" | ||
} | ||
} |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./lib/zod-openapi"), exports); | ||
__exportStar(require("./lib/zod-openapi"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -16,7 +16,6 @@ "use strict"; | ||
const input = generateSchema(zodRef._def.schema, useOutput); | ||
zodRef._def; //? | ||
let output = 'undefined'; | ||
if (useOutput && zodRef._def.effects && zodRef._def.effects.length > 0) { | ||
const effect = zodRef._def.effects | ||
.filter((ef) => ef.type === 'transform') | ||
.slice(-1)[0]; | ||
if (useOutput && zodRef._def.effect) { | ||
const effect = zodRef._def.effect.type === 'transform' ? zodRef._def.effect : null; | ||
if (effect && 'transform' in effect) { | ||
@@ -43,3 +42,3 @@ try { | ||
} | ||
return ts_deepmerge_1.default(Object.assign(Object.assign({}, input), (['number', 'string', 'boolean', 'null'].includes(output) | ||
return (0, ts_deepmerge_1.default)(Object.assign(Object.assign({}, input), (['number', 'string', 'boolean', 'null'].includes(output) | ||
? { | ||
@@ -77,3 +76,3 @@ type: output, | ||
}); | ||
return ts_deepmerge_1.default(baseSchema, ...schemas); | ||
return (0, ts_deepmerge_1.default)(baseSchema, ...schemas); | ||
} | ||
@@ -98,6 +97,6 @@ function parseNumber({ zodRef, schemas, }) { | ||
}); | ||
return ts_deepmerge_1.default(baseSchema, ...schemas); | ||
return (0, ts_deepmerge_1.default)(baseSchema, ...schemas); | ||
} | ||
function parseObject({ zodRef, schemas, useOutput, }) { | ||
return ts_deepmerge_1.default({ | ||
return (0, ts_deepmerge_1.default)({ | ||
type: 'object', | ||
@@ -114,12 +113,12 @@ properties: iterateZodObject({ | ||
function parseBigInt({ schemas }) { | ||
return ts_deepmerge_1.default({ type: 'integer', format: 'int64' }, ...schemas); | ||
return (0, ts_deepmerge_1.default)({ type: 'integer', format: 'int64' }, ...schemas); | ||
} | ||
function parseBoolean({ schemas }) { | ||
return ts_deepmerge_1.default({ type: 'boolean' }, ...schemas); | ||
return (0, ts_deepmerge_1.default)({ type: 'boolean' }, ...schemas); | ||
} | ||
function parseDate({ schemas }) { | ||
return ts_deepmerge_1.default({ type: 'string', format: 'date-time' }, ...schemas); | ||
return (0, ts_deepmerge_1.default)({ type: 'string', format: 'date-time' }, ...schemas); | ||
} | ||
function parseNull({ schemas }) { | ||
return ts_deepmerge_1.default({ | ||
return (0, ts_deepmerge_1.default)({ | ||
type: 'string', | ||
@@ -131,6 +130,6 @@ format: 'null', | ||
function parseOptionalNullable({ schemas, zodRef, useOutput, }) { | ||
return ts_deepmerge_1.default(generateSchema(zodRef.unwrap(), useOutput), ...schemas); | ||
return (0, ts_deepmerge_1.default)(generateSchema(zodRef.unwrap(), useOutput), ...schemas); | ||
} | ||
function parseArray({ schemas, zodRef, useOutput, }) { | ||
return ts_deepmerge_1.default({ | ||
return (0, ts_deepmerge_1.default)({ | ||
type: 'array', | ||
@@ -141,3 +140,3 @@ items: generateSchema(zodRef._def.type, useOutput), | ||
function parseLiteral({ schemas, zodRef, }) { | ||
return ts_deepmerge_1.default({ | ||
return (0, ts_deepmerge_1.default)({ | ||
type: typeof zodRef._def.value, | ||
@@ -148,3 +147,3 @@ enum: [zodRef._def.value], | ||
function parseEnum({ schemas, zodRef, }) { | ||
return ts_deepmerge_1.default({ | ||
return (0, ts_deepmerge_1.default)({ | ||
type: typeof Object.values(zodRef._def.values)[0], | ||
@@ -155,3 +154,3 @@ enum: Object.values(zodRef._def.values), | ||
function parseIntersection({ schemas, zodRef, useOutput, }) { | ||
return ts_deepmerge_1.default({ | ||
return (0, ts_deepmerge_1.default)({ | ||
allOf: [ | ||
@@ -164,3 +163,3 @@ generateSchema(zodRef._def.left, useOutput), | ||
function parseUnion({ schemas, zodRef, useOutput, }) { | ||
return ts_deepmerge_1.default({ | ||
return (0, ts_deepmerge_1.default)({ | ||
oneOf: zodRef._def.options.map((schema) => generateSchema(schema, useOutput)), | ||
@@ -170,6 +169,6 @@ }, ...schemas); | ||
function parseNever({ schemas }) { | ||
return ts_deepmerge_1.default({ readOnly: true }, ...schemas); | ||
return (0, ts_deepmerge_1.default)({ readOnly: true }, ...schemas); | ||
} | ||
function catchAllParser({ schemas }) { | ||
return ts_deepmerge_1.default(...schemas); | ||
return (0, ts_deepmerge_1.default)(...schemas); | ||
} | ||
@@ -176,0 +175,0 @@ const workerMap = { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
19818
238
0