openapi-ts-json-schema
Version:
OpenAPI to JSON schema generator with TypeScript in mind
26 lines (25 loc) • 977 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeId = void 0;
const node_path_1 = __importDefault(require("node:path"));
const _1 = require(".");
/**
* Generate schema internal id
*/
const TRALING_SLASH_REGEX = /\/$/;
function makeId({ schemaRelativeDirName, schemaName, }) {
const normalizedSchemaRelativeDirName = '/' +
node_path_1.default
.normalize(schemaRelativeDirName)
// Supporting definitionPathsToGenerateFrom dot notation
.replaceAll('.', '/')
// Replace windows backslashes \
.replaceAll('\\', '/')
.replace(TRALING_SLASH_REGEX, '');
// Shall we replace '/' with a different separator?
return normalizedSchemaRelativeDirName + '/' + (0, _1.filenamify)(schemaName);
}
exports.makeId = makeId;