UNPKG

openapi-codegen-typescript

Version:

OpenApi codegen for generating types an mocks from swagger json file

19 lines (18 loc) 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var types_1 = require("../types"); var getDescription_1 = require("./getDescription"); var parseFormat_1 = require("./parseFormat"); var parsePropertyName_1 = require("./parsePropertyName"); exports.getResultStringForStringType = function (_a) { var propertyName = _a.propertyName, description = _a.description, nullable = _a.nullable, format = _a.format, minLength = _a.minLength, maxLength = _a.maxLength; var nameAndValue = parsePropertyName_1.parsePropertyName({ propertyName: propertyName, nullable: nullable, type: 'string' }); var formatString = parseFormat_1.parseFormat(format); var minString = minLength ? "" + (format ? '; ' : '') + types_1.StringAdditionalProps.MinLength + ": " + minLength : ''; var maxString = maxLength ? "" + (format || minLength ? '; ' : '') + types_1.StringAdditionalProps.MaxLength + ": " + maxLength : ''; var shouldShowDocs = format || minLength || maxLength; var documentation = "" + formatString + minString + maxString; return "" + getDescription_1.getDescription({ description: description }) + nameAndValue + (shouldShowDocs ? " // " + documentation : '') + "\n"; };