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.86 kB
JavaScript
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.EnumGenerator = void 0;
var _ = require("lodash");
var base_generator_1 = require("./base.generator");
var EnumGenerator = /** @class */ (function (_super) {
__extends(EnumGenerator, _super);
function EnumGenerator(options) {
var _this = this;
var _a;
_this = _super.call(this, options, (_a = options.templates) === null || _a === void 0 ? void 0 : _a.enum) || this;
_this.GeneratorName = 'EnumGenerator';
return _this;
}
EnumGenerator.prototype.generate = function (templateData) {
var _this = this;
var _a;
(_a = templateData.entities) === null || _a === void 0 ? void 0 : _a.filter(function (entity) { return entity.isEnum; }).forEach(function (entity) {
_super.prototype.generateFile.call(_this, "".concat(_this.generatorOptions.outputPath, "/").concat(_.kebabCase(entity.name), ".enum.ts"), entity);
});
};
return EnumGenerator;
}(base_generator_1.BaseGenerator));
exports.EnumGenerator = EnumGenerator;
;