'use strict'; // ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@standard-community/standard-openapi/0.2.9/c6654ad467b946e76ea6469e89dabcbc2ea42f7aab1c3771372baf5d5c988ab0/node_modules/@standard-community/standard-openapi/dist/vendors/convert.js function convertToOpenAPISchema(jsonSchema, context) { const _jsonSchema = JSON.parse(JSON.stringify(jsonSchema)); if ("nullable" in _jsonSchema && _jsonSchema.nullable === true) { if (_jsonSchema.type) { if (Array.isArray(_jsonSchema.type)) { if (!_jsonSchema.type.includes("null")) { _jsonSchema.type.push("null"); } } else { _jsonSchema.type = [_jsonSchema.type, "null"]; } } else { _jsonSchema.type = ["null"]; } delete _jsonSchema.nullable; } if (_jsonSchema.$schema) { delete _jsonSchema.$schema; } const nestedSchemaKeys = [ "properties", "additionalProperties", "items", "additionalItems", "allOf", "anyOf", "oneOf", "not", "if", "then", "else", "definitions", "$defs", "patternProperties", "propertyNames", "contains" // "unevaluatedProperties", // "unevaluatedItems", ]; nestedSchemaKeys.forEach((key) => { if (_jsonSchema[key] && (typeof _jsonSchema[key] === "object" || Array.isArray(_jsonSchema[key]))) { if (key === "properties" || key === "definitions" || key === "$defs" || key === "patternProperties") { for (const subKey in _jsonSchema[key]) { _jsonSchema[key][subKey] = convertToOpenAPISchema( _jsonSchema[key][subKey], context ); } } else if (key === "allOf" || key === "anyOf" || key === "oneOf") { _jsonSchema[key] = _jsonSchema[key].map( (item) => convertToOpenAPISchema(item, context) ); } else if (key === "items") { if (Array.isArray(_jsonSchema[key])) { _jsonSchema[key] = _jsonSchema[key].map( (item) => convertToOpenAPISchema(item, context) ); } else { _jsonSchema[key] = convertToOpenAPISchema(_jsonSchema[key], context); } } else { _jsonSchema[key] = convertToOpenAPISchema(_jsonSchema[key], context); } } }); if (_jsonSchema.ref || _jsonSchema.$id) { const { ref, $id, ...component } = _jsonSchema; const id = ref || $id; context.components.schemas = { ...context.components.schemas, [id]: component }; return { $ref: `#/components/schemas/${id}` }; } else if (_jsonSchema.$ref) { const { $ref, $defs } = _jsonSchema; const ref = $ref.split("/").pop(); context.components.schemas = { ...context.components.schemas, ...$defs }; return { $ref: `#/components/schemas/${ref}` }; } return _jsonSchema; } exports.convertToOpenAPISchema = convertToOpenAPISchema; //# sourceMappingURL=chunk-46M65MQG.cjs.map //# sourceMappingURL=chunk-46M65MQG.cjs.map