UNPKG

@igli.kokici/st-open-api

Version:

Generates API client SDKs from an OpenAPI specification written in OpenAPI version 3.x.x

64 lines 2.31 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); var path_1 = require("path"); exports.GROUP_SERVICE = 'SERVICE'; var Ref = /** @class */ (function () { function Ref() { var _this = this; this.refs = {}; this.groups = {}; this.getImportAndTypeByRef = function (ref, path) { var reference = _this.refs[ref]; var relativePath = path_1.relative(path, reference.folderPath).split(path_1.sep).join('/'); if (!relativePath) { relativePath = './'; } else { if (!relativePath.startsWith('../')) { relativePath = "./" + relativePath; } relativePath += '/'; } return { className: reference.className, import: "import {" + reference.className + "} from '" + relativePath + reference.fileName + "';", schema: reference.schema }; }; this.addReference = function (refKey, data, group) { if (group === void 0) { group = undefined; } var ref = { fileName: data.fileName, className: data.className, folderPath: data.folderPath, schema: data === null || data === void 0 ? void 0 : data.schema }; _this.refs[refKey] = ref; if (!!group) { var groupArr = _this.groups[group]; if (!groupArr) { groupArr = []; _this.groups[group] = groupArr; } groupArr.push(__assign(__assign({}, ref), { refKey: refKey })); } }; } Ref.prototype.getByGroup = function (group) { return this.groups[group] || []; }; return Ref; }()); exports.Ref = Ref; //# sourceMappingURL=ref.js.map