UNPKG

@igli.kokici/st-open-api

Version:

Generates API client SDKs from an OpenAPI specification written in OpenAPI version 3.x.x

50 lines 1.96 kB
"use strict"; 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 }); var render_mustache_1 = require("../function/render-mustache"); var config_1 = require("../function/config"); var formatText_1 = require("../function/formatText"); var EnumProperty = /** @class */ (function () { function EnumProperty(originalName) { this.values = []; this.convertName(originalName); } EnumProperty.prototype.convertName = function (originalName) { this.enumName = formatText_1.formatText(originalName, 'ANY', 'PascalCase'); this.fileName = formatText_1.formatText(originalName, 'ANY', 'KebabCase'); }; EnumProperty.prototype.setValues = function (values) { this.values = values.map(function (value) { return { isString: typeof value === 'string', value: value.toString() }; }); }; EnumProperty.prototype.render = function () { var viewData = { enumName: this.enumName, // DO NOT SORT ARRAYS values: this.values .map((function (value, index, arr) { return (__assign(__assign({}, value), { last: index === arr.length - 1 })); })) }; return { classEnumName: this.enumName, fileName: this.fileName, render: render_mustache_1.renderMustache((config_1.configuration.isType() ? 'type' : 'enum') + ".mustache", viewData) }; }; return EnumProperty; }()); exports.EnumProperty = EnumProperty; //# sourceMappingURL=enum-property.js.map