alapa
Version:
A cutting-edge web development framework designed to revolutionize the way developers build modern web applications.
59 lines (58 loc) • 2.67 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildPaths = buildPaths;
const entry_1 = require("./entry");
const parameter_1 = require("./parameter");
const request_body_1 = require("./request-body");
const response_1 = require("./response");
function buildPaths() {
const collections = entry_1.temporalCollections["routes"] ?? {};
const allGeneralTags = entry_1.temporalCollections["generalTags"] ?? {};
Object.keys(collections).forEach((key) => {
const route = collections[key];
entry_1.openApiDefinitionsPaths[key] = {};
Object.keys(route).forEach((method) => {
entry_1.openApiDefinitionsPaths[key][method] = {};
const data = route[method];
console.log(data);
const operationId = method +
"-" +
key
.trim()
.replace(/[\W.]+/g, "-")
.replace(/^[-]+|[-]+$/g, "");
entry_1.openApiDefinitionsPaths[key][method]["operationId"] = operationId;
if (data["summary"]) {
entry_1.openApiDefinitionsPaths[key][method]["summary"] = data["summary"];
}
if (data["description"]) {
entry_1.openApiDefinitionsPaths[key][method]["description"] =
data["description"];
}
if (data["tags"] && Array.isArray(data["tags"])) {
entry_1.openApiDefinitionsPaths[key][method]["tags"] = data["tags"];
}
if (data["security"]) {
entry_1.openApiDefinitionsPaths[key][method]["security"] = data["security"];
}
if (data["responses"]) {
entry_1.openApiDefinitionsPaths[key][method]["responses"] = (0, response_1.buildResponse)(data["responses"]);
}
if (data["parameters"]) {
entry_1.openApiDefinitionsPaths[key][method]["parameters"] = (0, parameter_1.buildParameter)(data["parameters"]);
}
if (data["requestBody"]) {
entry_1.openApiDefinitionsPaths[key][method]["requestBody"] = (0, request_body_1.buildRequestBody)(data["requestBody"]);
}
let tags = data["tags"] || [];
if (typeof tags === "string") {
tags = tags.split(",");
}
let generalTags = allGeneralTags[key] || [];
if (typeof generalTags === "string") {
generalTags = generalTags.split(",");
}
entry_1.openApiDefinitionsPaths[key][method]["tags"] = [...generalTags, ...tags];
});
});
}