UNPKG

openapi-ts-json-schema

Version:

OpenAPI to JSON schema generator with TypeScript in mind

16 lines (15 loc) 585 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.replacePlaceholdersWithRefs = void 0; const __1 = require(".."); /** * Replace id placeholders with their relevant $ref object */ function replacePlaceholdersWithRefs({ schemaAsText, refMapper, }) { // Replace placeholder occurrences with a JSON schema $ref object let output = schemaAsText.replaceAll(__1.PLACEHOLDER_REGEX, (_match, id) => { return `{ $ref: "${refMapper({ id })}" }`; }); return output; } exports.replacePlaceholdersWithRefs = replacePlaceholdersWithRefs;