UNPKG

openapi-codegen-typescript

Version:

OpenApi codegen for generating types an mocks from swagger json file

23 lines (22 loc) 1.59 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"); var parseRefType_1 = require("./parseRefType"); exports.getResultStringForArrayType = function (_a) { var propertyName = _a.propertyName, description = _a.description, nullable = _a.nullable, refType = _a.refType, format = _a.format, minItems = _a.minItems, maxItems = _a.maxItems, uniqueItems = _a.uniqueItems; var nameAndValue = parsePropertyName_1.parsePropertyName({ propertyName: propertyName, nullable: nullable, type: parseRefType_1.parseRefType(refType) + "[]" }); var formatString = parseFormat_1.parseFormat(format); var minItemsString = minItems ? "" + (format ? '; ' : '') + types_1.ArrayAdditionalProps.MinItems + ": " + minItems : ''; var maxItemsString = maxItems ? "" + (format || minItems ? '; ' : '') + types_1.ArrayAdditionalProps.MaxItems + ": " + maxItems : ''; var uniqueItemsString = uniqueItems ? "" + (format || minItems || maxItems ? '; ' : '') + types_1.ArrayAdditionalProps.UniqueItems + ": " + uniqueItems : ''; var shouldShowDocs = format || minItems || maxItems || uniqueItems; var documentation = "" + formatString + minItemsString + maxItemsString + uniqueItemsString; return "" + getDescription_1.getDescription({ description: description }) + nameAndValue + (shouldShowDocs ? " // " + documentation : '') + "\n"; };