@nestjs/swagger
Advanced tools
Comparing version 4.1.5 to 4.1.6
@@ -9,1 +9,2 @@ import { SchemaObjectMetadata } from '../interfaces/schema-object-metadata.interface'; | ||
export declare function ApiResponseProperty(options?: Pick<ApiPropertyOptions, 'type' | 'example' | 'format' | 'enum' | 'deprecated'>): PropertyDecorator; | ||
export declare function createApiPropertyDecorator(options?: ApiPropertyOptions, overrideExisting?: boolean): PropertyDecorator; |
@@ -8,2 +8,14 @@ "use strict"; | ||
function ApiProperty(options = {}) { | ||
return createApiPropertyDecorator(options); | ||
} | ||
exports.ApiProperty = ApiProperty; | ||
function ApiPropertyOptional(options = {}) { | ||
return ApiProperty(Object.assign(Object.assign({}, options), { required: false })); | ||
} | ||
exports.ApiPropertyOptional = ApiPropertyOptional; | ||
function ApiResponseProperty(options = {}) { | ||
return ApiProperty(Object.assign({ readOnly: true }, options)); | ||
} | ||
exports.ApiResponseProperty = ApiResponseProperty; | ||
function createApiPropertyDecorator(options = {}, overrideExisting = true) { | ||
const [type, isArray] = helpers_1.getTypeIsArrayTuple(options.type, options.isArray); | ||
@@ -26,12 +38,4 @@ options = Object.assign(Object.assign({}, options), { type, | ||
} | ||
return helpers_1.createPropertyDecorator(constants_1.DECORATORS.API_MODEL_PROPERTIES, options); | ||
return helpers_1.createPropertyDecorator(constants_1.DECORATORS.API_MODEL_PROPERTIES, options, overrideExisting); | ||
} | ||
exports.ApiProperty = ApiProperty; | ||
function ApiPropertyOptional(options = {}) { | ||
return ApiProperty(Object.assign(Object.assign({}, options), { required: false })); | ||
} | ||
exports.ApiPropertyOptional = ApiPropertyOptional; | ||
function ApiResponseProperty(options = {}) { | ||
return ApiProperty(Object.assign({ readOnly: true }, options)); | ||
} | ||
exports.ApiResponseProperty = ApiResponseProperty; | ||
exports.createApiPropertyDecorator = createApiPropertyDecorator; |
export declare function createMethodDecorator<T = any>(metakey: string, metadata: T): MethodDecorator; | ||
export declare function createClassDecorator<T extends Array<any> = any>(metakey: string, metadata?: T): ClassDecorator; | ||
export declare function createPropertyDecorator<T extends Record<string, any> = any>(metakey: string, metadata: T): PropertyDecorator; | ||
export declare function createPropertyDecorator<T extends Record<string, any> = any>(metakey: string, metadata: T, overrideExisting?: boolean): PropertyDecorator; | ||
export declare function createMixedDecorator<T = any>(metakey: string, metadata: T): any; | ||
export declare function createParamDecorator<T extends Record<string, any> = any>(metadata: T, initial: Partial<T>): MethodDecorator; | ||
export declare function getTypeIsArrayTuple(input: Function | [Function] | undefined | string, isArrayFlag: boolean): [Function | undefined, boolean]; |
@@ -20,3 +20,3 @@ "use strict"; | ||
exports.createClassDecorator = createClassDecorator; | ||
function createPropertyDecorator(metakey, metadata) { | ||
function createPropertyDecorator(metakey, metadata, overrideExisting = true) { | ||
return (target, propertyKey) => { | ||
@@ -30,3 +30,6 @@ const properties = Reflect.getMetadata(constants_1.DECORATORS.API_MODEL_PROPERTIES_ARRAY, target) || []; | ||
if (existingMetadata) { | ||
Reflect.defineMetadata(metakey, Object.assign(Object.assign({}, existingMetadata), lodash_1.pickBy(metadata, lodash_1.negate(lodash_1.isUndefined))), target, propertyKey); | ||
const newMetadata = lodash_1.pickBy(metadata, lodash_1.negate(lodash_1.isUndefined)); | ||
const metadataToSave = overrideExisting | ||
? Object.assign(Object.assign({}, existingMetadata), newMetadata) : Object.assign(Object.assign({}, newMetadata), existingMetadata); | ||
Reflect.defineMetadata(metakey, metadataToSave, target, propertyKey); | ||
} | ||
@@ -33,0 +36,0 @@ else { |
@@ -13,3 +13,3 @@ export * from './api-basic.decorator'; | ||
export * from './api-produces.decorator'; | ||
export * from './api-property.decorator'; | ||
export { ApiProperty, ApiPropertyOptional, ApiPropertyOptions, ApiResponseProperty } from './api-property.decorator'; | ||
export * from './api-query.decorator'; | ||
@@ -16,0 +16,0 @@ export * from './api-response.decorator'; |
@@ -18,3 +18,6 @@ "use strict"; | ||
__export(require("./api-produces.decorator")); | ||
__export(require("./api-property.decorator")); | ||
var api_property_decorator_1 = require("./api-property.decorator"); | ||
exports.ApiProperty = api_property_decorator_1.ApiProperty; | ||
exports.ApiPropertyOptional = api_property_decorator_1.ApiPropertyOptional; | ||
exports.ApiResponseProperty = api_property_decorator_1.ApiResponseProperty; | ||
__export(require("./api-query.decorator")); | ||
@@ -21,0 +24,0 @@ __export(require("./api-response.decorator")); |
@@ -6,3 +6,3 @@ "use strict"; | ||
const constants_1 = require("../constants"); | ||
const decorators_1 = require("../decorators"); | ||
const api_property_decorator_1 = require("../decorators/api-property.decorator"); | ||
const plugin_constants_1 = require("../plugin/plugin-constants"); | ||
@@ -28,3 +28,3 @@ class ModelPropertiesAccessor { | ||
properties.forEach(key => { | ||
decorators_1.ApiProperty(metadata[key])(prototype, key); | ||
api_property_decorator_1.createApiPropertyDecorator(metadata[key], false)(prototype, key); | ||
}); | ||
@@ -31,0 +31,0 @@ } |
@@ -11,2 +11,3 @@ "use strict"; | ||
const is_built_in_type_util_1 = require("../utils/is-built-in-type.util"); | ||
const is_date_ctor_util_1 = require("../utils/is-date-ctor.util"); | ||
class SchemaObjectFactory { | ||
@@ -88,2 +89,11 @@ constructor(modelPropertiesAccessor, swaggerTypesMapper) { | ||
} | ||
if (is_date_ctor_util_1.isDateCtor(metadata.type)) { | ||
if (metadata.isArray) { | ||
return this.transformToArraySchemaProperty(metadata, key, { | ||
format: metadata.format || 'date-time', | ||
type: 'string' | ||
}); | ||
} | ||
return Object.assign(Object.assign({ format: 'date-time' }, metadata), { type: 'string', name: metadata.name || key }); | ||
} | ||
if (!is_built_in_type_util_1.isBuiltInType(metadata.type)) { | ||
@@ -90,0 +100,0 @@ return this.createNotBuiltInTypeReference(key, metadata, schemas, schemaRefsStack); |
{ | ||
"name": "@nestjs/swagger", | ||
"version": "4.1.5", | ||
"version": "4.1.6", | ||
"description": "Nest - modern, fast, powerful node.js web framework (@swagger)", | ||
@@ -33,3 +33,3 @@ "author": "Kamil Mysliwiec", | ||
"fastify-swagger": "2.5.0", | ||
"husky": "4.0.0", | ||
"husky": "4.0.1", | ||
"jest": "24.9.0", | ||
@@ -36,0 +36,0 @@ "lint-staged": "9.5.0", |
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
158692
172
3059