UNPKG

swagger-typescript-generator

Version:

Generate typescript code from swagger.json. Before start this project I try use [swagger-typescript-codegen](https://github.com/mtennoe/swagger-typescript-codegen) based on [mustache templates](https://github.com/mtennoe/swagger-js-codegen/tree/master/lib

121 lines 4.24 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 (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); 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 }); exports.ModelType = void 0; var object_ex_1 = require("./object-ex"); var ModelType = /** @class */ (function (_super) { __extends(ModelType, _super); function ModelType(config) { var _this = _super.call(this) || this; _this.setPrivate('config', config); return _this; } Object.defineProperty(ModelType.prototype, "type", { get: function () { if (this.getPrivate('type')) { return this.getPrivate('type'); } if (this.enumRef) { return this.isArray ? "Array<" + this.arrayItemType + ">" : this.enumRef.getFullName; } if (this.modelRef) { return this.isArray ? "Array<" + this.arrayItemType + ">" : this.modelRef.name; } return ''; }, set: function (val) { this.setPrivate('type', val); }, enumerable: false, configurable: true }); Object.defineProperty(ModelType.prototype, "arrayItemType", { get: function () { if (this.getPrivate('arrayItemType')) { return this.getPrivate('arrayItemType'); } if (this.enumRef && this.isArray) { return this.enumRef.getFullName; } if (this.modelRef && this.isArray) { return this.modelRef.name; } return undefined; }, set: function (val) { this.setPrivate('arrayItemType', val); }, enumerable: false, configurable: true }); Object.defineProperty(ModelType.prototype, "modelRef", { get: function () { return this.getPrivate('modelRef'); }, set: function (val) { if (val) { // reset type and array item type when ref exist! this.type = ''; this.arrayItemType = ''; } this.setPrivate('modelRef', val); }, enumerable: false, configurable: true }); Object.defineProperty(ModelType.prototype, "enumRef", { get: function () { return this.getPrivate('enumRef'); }, set: function (val) { if (val) { // reset type and array item type when ref exist! this.type = ''; this.arrayItemType = ''; } this.setPrivate('enumRef', val); }, enumerable: false, configurable: true }); Object.defineProperty(ModelType.prototype, "config", { get: function () { return this.getPrivate('config'); }, enumerable: false, configurable: true }); ModelType.prototype.toJSON = function () { var privateFields = this.config.showPrivateFieldsForDebug ? { enumRef: this.enumRef, modelRef: this.modelRef } : {}; return __assign(__assign(__assign({}, this), { type: this.type, arrayItemType: this.arrayItemType }), privateFields); }; return ModelType; }(object_ex_1.ObjectEx)); exports.ModelType = ModelType; //# sourceMappingURL=model-type.js.map