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
76 lines • 3 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 (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.SwaggerEnum = void 0;
var swagger_base_1 = require("./swagger-base");
var utils_1 = require("./utils");
var SwaggerEnum = /** @class */ (function (_super) {
__extends(SwaggerEnum, _super);
function SwaggerEnum(parent, key, model, source) {
var _this = _super.call(this) || this;
_this.name = '';
_this.duplicateNamespaces = [];
_this.parent = parent;
_this.source = source;
_this.keys = [];
_this.keys.push(key);
var name = _this.utils.getEnumName(key);
_this.name = name;
_this.fileName = _this.utils.getEnumFileName(_this, key);
_this.enumValues = _this.utils.getEnumValues(source);
if (!_this.enumValues && model.methodPropertyDef) {
_this.enumValues = model.methodPropertyDef.modelType.enumValues
? model.methodPropertyDef.modelType.enumValues
: [];
}
if (!_this.enumValues && model.modelPropDef) {
_this.enumValues = model.modelPropDef.modelType.enumValues
? model.modelPropDef.modelType.enumValues
: [];
}
_this.description = source.description;
_this.type = source.type;
if (model.modelDef) {
_this.namespace = model.modelDef.name;
}
return _this;
}
Object.defineProperty(SwaggerEnum.prototype, "getFullName", {
get: function () {
return this.namespace ? this.namespace + "." + this.name : this.name;
},
enumerable: false,
configurable: true
});
SwaggerEnum.prototype.toJSON = function () {
var _a;
return __assign(__assign({}, this), (_a = {}, _a[utils_1.nameof('getFullName')] = this.getFullName, _a));
};
SwaggerEnum.prototype.init = function () { };
return SwaggerEnum;
}(swagger_base_1.SwaggerBase));
exports.SwaggerEnum = SwaggerEnum;
//# sourceMappingURL=swagger-enum.js.map