UNPKG

openapi-ts-generator

Version:

Based on swagger-ts-generator, this is a type script model generator specifically for services with OpenApi spec documentation.

40 lines (39 loc) 1.96 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.BarrelGenerator = void 0; var fs_1 = require("fs"); var base_generator_1 = require("./base.generator"); var BarrelGenerator = /** @class */ (function (_super) { __extends(BarrelGenerator, _super); function BarrelGenerator(options) { var _this = this; var _a; _this = _super.call(this, options, (_a = options.templates) === null || _a === void 0 ? void 0 : _a.barrel) || this; _this.GeneratorName = 'BarrelGenerator'; _this.tsRegex = /.ts$/; return _this; } BarrelGenerator.prototype.generate = function () { var _this = this; var fileNames = (0, fs_1.readdirSync)(this.generatorOptions.outputPath).map(function (value) { return value.replace(_this.tsRegex, ''); }); fileNames = fileNames.filter(function (x) { return x !== 'endpoints'; }); return _super.prototype.generateFile.call(this, "".concat(this.generatorOptions.outputPath, "/index.ts"), fileNames.length ? { fileNames: fileNames } : null); }; return BarrelGenerator; }(base_generator_1.BaseGenerator)); exports.BarrelGenerator = BarrelGenerator;