full site update

This commit is contained in:
2025-07-24 18:46:24 +02:00
parent bfe2b90d8d
commit 37a6e0ab31
6912 changed files with 540482 additions and 361712 deletions

View File

@@ -3,15 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.zodToJsonSchema = void 0;
const parseDef_js_1 = require("./parseDef.js");
const Refs_js_1 = require("./Refs.js");
const any_js_1 = require("./parsers/any.js");
const zodToJsonSchema = (schema, options) => {
const refs = (0, Refs_js_1.getRefs)(options);
const definitions = typeof options === "object" && options.definitions
let definitions = typeof options === "object" && options.definitions
? Object.entries(options.definitions).reduce((acc, [name, schema]) => ({
...acc,
[name]: (0, parseDef_js_1.parseDef)(schema._def, {
...refs,
currentPath: [...refs.basePath, refs.definitionPath, name],
}, true) ?? {},
}, true) ?? (0, any_js_1.parseAnyDef)(refs),
}), {})
: undefined;
const name = typeof options === "string"
@@ -24,7 +25,7 @@ const zodToJsonSchema = (schema, options) => {
: {
...refs,
currentPath: [...refs.basePath, refs.definitionPath, name],
}, false) ?? {};
}, false) ?? (0, any_js_1.parseAnyDef)(refs);
const title = typeof options === "object" &&
options.name !== undefined &&
options.nameStrategy === "title"
@@ -33,6 +34,26 @@ const zodToJsonSchema = (schema, options) => {
if (title !== undefined) {
main.title = title;
}
if (refs.flags.hasReferencedOpenAiAnyType) {
if (!definitions) {
definitions = {};
}
if (!definitions[refs.openAiAnyTypeName]) {
definitions[refs.openAiAnyTypeName] = {
// Skipping "object" as no properties can be defined and additionalProperties must be "false"
type: ["string", "number", "integer", "boolean", "array", "null"],
items: {
$ref: refs.$refStrategy === "relative"
? "1"
: [
...refs.basePath,
refs.definitionPath,
refs.openAiAnyTypeName,
].join("/"),
},
};
}
}
const combined = name === undefined
? definitions
? {