full site update
This commit is contained in:
16
node_modules/zod-to-json-schema/dist/cjs/parseDef.js
generated
vendored
16
node_modules/zod-to-json-schema/dist/cjs/parseDef.js
generated
vendored
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseDef = void 0;
|
||||
const Options_js_1 = require("./Options.js");
|
||||
const selectParser_js_1 = require("./selectParser.js");
|
||||
const getRelativePath_js_1 = require("./getRelativePath.js");
|
||||
const any_js_1 = require("./parsers/any.js");
|
||||
function parseDef(def, refs, forceResolution = false) {
|
||||
const seenItem = refs.seen.get(def);
|
||||
if (refs.override) {
|
||||
@@ -41,26 +43,18 @@ const get$ref = (item, refs) => {
|
||||
case "root":
|
||||
return { $ref: item.path.join("/") };
|
||||
case "relative":
|
||||
return { $ref: getRelativePath(refs.currentPath, item.path) };
|
||||
return { $ref: (0, getRelativePath_js_1.getRelativePath)(refs.currentPath, item.path) };
|
||||
case "none":
|
||||
case "seen": {
|
||||
if (item.path.length < refs.currentPath.length &&
|
||||
item.path.every((value, index) => refs.currentPath[index] === value)) {
|
||||
console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
|
||||
return {};
|
||||
return (0, any_js_1.parseAnyDef)(refs);
|
||||
}
|
||||
return refs.$refStrategy === "seen" ? {} : undefined;
|
||||
return refs.$refStrategy === "seen" ? (0, any_js_1.parseAnyDef)(refs) : undefined;
|
||||
}
|
||||
}
|
||||
};
|
||||
const getRelativePath = (pathA, pathB) => {
|
||||
let i = 0;
|
||||
for (; i < pathA.length && i < pathB.length; i++) {
|
||||
if (pathA[i] !== pathB[i])
|
||||
break;
|
||||
}
|
||||
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
||||
};
|
||||
const addMeta = (def, refs, jsonSchema) => {
|
||||
if (def.description) {
|
||||
jsonSchema.description = def.description;
|
||||
|
Reference in New Issue
Block a user