@nestjs/swagger
Advanced tools
Comparing version 4.0.0-next.4 to 4.0.0-next.5
@@ -1,1 +0,1 @@ | ||
export declare function ApiOAuth2Auth(scopes: string[], name?: string): (target: object, key?: string | symbol, descriptor?: TypedPropertyDescriptor<any>) => any; | ||
export declare function ApiOAuth2(scopes: string[], name?: string): (target: object, key?: string | symbol, descriptor?: TypedPropertyDescriptor<any>) => any; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const api_security_decorator_1 = require("./api-security.decorator"); | ||
function ApiOAuth2Auth(scopes, name = 'oauth2') { | ||
function ApiOAuth2(scopes, name = 'oauth2') { | ||
return api_security_decorator_1.ApiSecurity(name, scopes); | ||
} | ||
exports.ApiOAuth2Auth = ApiOAuth2Auth; | ||
exports.ApiOAuth2 = ApiOAuth2; |
@@ -12,4 +12,5 @@ import { Decorator, PropertyDeclaration } from 'ts-morph'; | ||
createEnumPropertyAssignment(node: PropertyDeclaration, existingProperties: ts.PropertyAssignment[]): ts.PropertyAssignment; | ||
createDefaultPropertyAssignment(node: PropertyDeclaration, existingProperties: ts.PropertyAssignment[]): ts.PropertyAssignment; | ||
createValidationPropertyAssignments(node: PropertyDeclaration): ts.PropertyAssignment[]; | ||
addPropertyByValidationDecorator(decoratorName: string, propertyKey: string, decorators: Decorator[], assignments: ts.PropertyAssignment[]): void; | ||
} |
@@ -74,2 +74,3 @@ "use strict"; | ||
this.createTypePropertyAssignment(node, existingProperties), | ||
this.createDefaultPropertyAssignment(node, existingProperties), | ||
this.createEnumPropertyAssignment(node, existingProperties) | ||
@@ -83,3 +84,4 @@ ]; | ||
createTypePropertyAssignment(node, existingProperties) { | ||
if (plugin_utils_1.hasPropertyKey('type', existingProperties)) { | ||
const key = 'type'; | ||
if (plugin_utils_1.hasPropertyKey(key, existingProperties)) { | ||
return undefined; | ||
@@ -95,6 +97,7 @@ } | ||
} | ||
return ts.createPropertyAssignment('type', ts.createArrowFunction(undefined, undefined, [], undefined, undefined, ts.createIdentifier(typeReference))); | ||
return ts.createPropertyAssignment(key, ts.createArrowFunction(undefined, undefined, [], undefined, undefined, ts.createIdentifier(typeReference))); | ||
} | ||
createEnumPropertyAssignment(node, existingProperties) { | ||
if (plugin_utils_1.hasPropertyKey('enum', existingProperties)) { | ||
const key = 'enum'; | ||
if (plugin_utils_1.hasPropertyKey(key, existingProperties)) { | ||
return undefined; | ||
@@ -109,4 +112,15 @@ } | ||
} | ||
return ts.createPropertyAssignment('enum', ts.createIdentifier(type.getText())); | ||
return ts.createPropertyAssignment(key, ts.createIdentifier(type.getText())); | ||
} | ||
createDefaultPropertyAssignment(node, existingProperties) { | ||
const key = 'default'; | ||
if (plugin_utils_1.hasPropertyKey(key, existingProperties)) { | ||
return undefined; | ||
} | ||
const initializer = node.getInitializer(); | ||
if (!initializer) { | ||
return undefined; | ||
} | ||
return ts.createPropertyAssignment(key, ts.createIdentifier(initializer.getText())); | ||
} | ||
createValidationPropertyAssignments(node) { | ||
@@ -113,0 +127,0 @@ const assignments = []; |
{ | ||
"name": "@nestjs/swagger", | ||
"version": "4.0.0-next.4", | ||
"version": "4.0.0-next.5", | ||
"description": "Nest - modern, fast, powerful node.js web framework (@swagger)", | ||
@@ -5,0 +5,0 @@ "author": "Kamil Mysliwiec", |
@@ -17,5 +17,5 @@ export const createCatDtoText = ` | ||
@Max(10) | ||
age: number; | ||
age: number = 3; | ||
tags: string[]; | ||
status: Status; | ||
status: Status = Status.ENABLED; | ||
@@ -40,2 +40,6 @@ @ApiProperty({ type: String }) | ||
export class CreateCatDto { | ||
constructor() { | ||
this.age = 3; | ||
this.status = Status.ENABLED; | ||
} | ||
} | ||
@@ -48,3 +52,3 @@ __decorate([ | ||
Max(10), | ||
openapi.ApiProperty({ required: true, type: () => Number, minimum: 0, maximum: 10 }) | ||
openapi.ApiProperty({ required: true, type: () => Number, default: 3, minimum: 0, maximum: 10 }) | ||
], CreateCatDto.prototype, \"age\", void 0); | ||
@@ -55,3 +59,3 @@ __decorate([ | ||
__decorate([ | ||
openapi.ApiProperty({ required: true, enum: Status }) | ||
openapi.ApiProperty({ required: true, default: Status.ENABLED, enum: Status }) | ||
], CreateCatDto.prototype, \"status\", void 0); | ||
@@ -58,0 +62,0 @@ __decorate([ |
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
206645
4474