@nestjs/swagger
Advanced tools
Comparing version 2.3.0 to 2.3.1
@@ -11,2 +11,3 @@ "use strict"; | ||
exports.ApiImplicitBody = (metadata) => { | ||
const [type, isArray] = helpers_1.getTypeIsArrayTuple(metadata.type, metadata.isArray); | ||
const param = { | ||
@@ -17,6 +18,6 @@ name: lodash_1.isNil(metadata.name) ? initialMetadata.name : metadata.name, | ||
required: metadata.required, | ||
type: metadata.type, | ||
isArray: metadata.isArray | ||
type, | ||
isArray | ||
}; | ||
return helpers_1.createParamDecorator(param, initialMetadata); | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const http_status_enum_1 = require("@nestjs/common/enums/http-status.enum"); | ||
const lodash_1 = require("lodash"); | ||
const constants_1 = require("../constants"); | ||
const http_status_enum_1 = require("@nestjs/common/enums/http-status.enum"); | ||
const helpers_1 = require("./helpers"); | ||
const initialMetadata = { | ||
@@ -12,2 +13,5 @@ status: 0, | ||
exports.ApiResponse = (metadata) => { | ||
const [type, isArray] = helpers_1.getTypeIsArrayTuple(metadata.type, metadata.isArray); | ||
metadata.type = type; | ||
metadata.isArray = isArray; | ||
metadata.description = metadata.description ? metadata.description : ''; | ||
@@ -14,0 +18,0 @@ const groupedMetadata = { [metadata.status]: lodash_1.omit(metadata, 'status') }; |
@@ -7,1 +7,2 @@ export declare const createMethodDecorator: (metakey: any, metadata: any) => MethodDecorator; | ||
export declare const createMultipleParamDecorator: (multiMetadata: any[], initial: any) => (target: any, key: any, descriptor: PropertyDescriptor) => PropertyDescriptor; | ||
export declare const getTypeIsArrayTuple: (input: Function | [Function], isArrayFlag: boolean) => [Function, boolean]; |
@@ -54,1 +54,12 @@ "use strict"; | ||
}; | ||
exports.getTypeIsArrayTuple = (input, isArrayFlag) => { | ||
if (!input) { | ||
return [Object, false]; | ||
} | ||
if (isArrayFlag) { | ||
return [input, isArrayFlag]; | ||
} | ||
const isInputArray = lodash_1.isArray(input); | ||
const type = isInputArray ? input[0] : input; | ||
return [type, isInputArray]; | ||
}; |
@@ -182,11 +182,11 @@ "use strict"; | ||
const { type } = param; | ||
const paramWithStringifiedType = lodash_1.pickBy(Object.assign({}, param, { type: type && shared_utils_1.isFunction(type) | ||
const paramWithStringType = lodash_1.pickBy(Object.assign({}, param, { type: type && shared_utils_1.isFunction(type) | ||
? exports.mapTypesToSwaggerTypes(type.name) | ||
: exports.mapTypesToSwaggerTypes(type) }), lodash_1.negate(shared_utils_1.isUndefined)); | ||
if (paramWithStringifiedType.isArray) { | ||
return Object.assign({}, paramWithStringifiedType, { type: 'array', items: { | ||
type: exports.mapTypesToSwaggerTypes(param.type) | ||
if (paramWithStringType.isArray) { | ||
return Object.assign({}, paramWithStringType, { type: 'array', items: { | ||
type: exports.mapTypesToSwaggerTypes(paramWithStringType.type) | ||
} }); | ||
} | ||
return paramWithStringifiedType; | ||
return paramWithStringType; | ||
}); | ||
@@ -205,2 +205,7 @@ exports.mapTypesToSwaggerTypes = (type) => { | ||
} | ||
const defaultTypes = [String, Boolean, Number, Object]; | ||
if (shared_utils_1.isFunction(param.type) && | ||
defaultTypes.some(defaultType => defaultType === param.type)) { | ||
return param; | ||
} | ||
const modelName = exports.exploreModelDefinition(param.type, definitions); | ||
@@ -207,0 +212,0 @@ const name = param.name ? param.name : modelName; |
{ | ||
"name": "@nestjs/swagger", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"description": | ||
@@ -5,0 +5,0 @@ "Nest - modern, fast, powerful node.js web framework (@swagger)", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76889
1335