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) 2.16 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.TestObjectFactoryGenerator = void 0; var _ = require("lodash"); var base_generator_1 = require("./base.generator"); var TestObjectFactoryGenerator = /** @class */ (function (_super) { __extends(TestObjectFactoryGenerator, _super); function TestObjectFactoryGenerator(options) { var _this = this; var _a; _this = _super.call(this, options, (_a = options.templates) === null || _a === void 0 ? void 0 : _a.testObjectFactory) || this; _this.GeneratorName = 'TestObjectFactoryGenerator'; return _this; } TestObjectFactoryGenerator.prototype.generate = function (templateData) { var _this = this; var _a; (_a = templateData.entities) === null || _a === void 0 ? void 0 : _a.filter(function (val) { var _a, _b; return ((_a = val.valueProperties) === null || _a === void 0 ? void 0 : _a.length) + ((_b = val.referenceProperties) === null || _b === void 0 ? void 0 : _b.length) > 0; }).forEach(function (entity) { _super.prototype.generateFile.call(_this, "".concat(_this.generatorOptions.outputPath, "/").concat(_.kebabCase(entity.name), ".test-obj-fac.ts"), entity); }); }; return TestObjectFactoryGenerator; }(base_generator_1.BaseGenerator)); exports.TestObjectFactoryGenerator = TestObjectFactoryGenerator;