@nestjs/swagger
Advanced tools
Comparing version 4.7.5 to 4.7.6
@@ -14,4 +14,4 @@ import { Decorator, Node, ObjectFlags, SourceFile, Type, TypeChecker, TypeFlags, TypeFormatFlags } from 'typescript'; | ||
export declare function getDefaultTypeFormatFlags(enclosingNode: Node): number; | ||
export declare function getMainCommentAndExamplesOfNode(node: Node, sourceFile: SourceFile, includeExamples?: boolean): [string, string[]]; | ||
export declare function getMainCommentAndExamplesOfNode(node: Node, sourceFile: SourceFile, typeChecker: TypeChecker, includeExamples?: boolean): [string, string[]]; | ||
export declare function getDecoratorArguments(decorator: Decorator): any[] | import("typescript").NodeArray<import("typescript").Expression>; | ||
export declare function getDecoratorName(decorator: Decorator): string; |
@@ -83,3 +83,3 @@ "use strict"; | ||
exports.getDefaultTypeFormatFlags = getDefaultTypeFormatFlags; | ||
function getMainCommentAndExamplesOfNode(node, sourceFile, includeExamples) { | ||
function getMainCommentAndExamplesOfNode(node, sourceFile, typeChecker, includeExamples) { | ||
const sourceText = sourceFile.getFullText(); | ||
@@ -101,8 +101,14 @@ const replaceRegex = /^ *\** *@.*$|^ *\/\*+ *|^ *\/\/+.*|^ *\/+ *|^ *\*+ *| +$| *\**\/ *$/gim; | ||
const example = execResult[1]; | ||
try { | ||
examplesResult.push(JSON.parse(example)); | ||
} | ||
catch (_a) { | ||
const type = typeChecker.getTypeAtLocation(node); | ||
if (type && isString(type)) { | ||
examplesResult.push(example); | ||
} | ||
else { | ||
try { | ||
examplesResult.push(JSON.parse(example)); | ||
} | ||
catch (_a) { | ||
examplesResult.push(example); | ||
} | ||
} | ||
} | ||
@@ -109,0 +115,0 @@ } |
@@ -7,3 +7,3 @@ import * as ts from 'typescript'; | ||
addDecoratorToNode(compilerNode: ts.MethodDeclaration, typeChecker: ts.TypeChecker, options: PluginOptions, hostFilename: string, sourceFile: ts.SourceFile): ts.MethodDeclaration; | ||
createApiOperationDecorator(node: ts.MethodDeclaration, nodeArray: ts.NodeArray<ts.Decorator>, options: PluginOptions, sourceFile: ts.SourceFile): ts.Decorator[]; | ||
createApiOperationDecorator(node: ts.MethodDeclaration, nodeArray: ts.NodeArray<ts.Decorator>, options: PluginOptions, sourceFile: ts.SourceFile, typeChecker: ts.TypeChecker): ts.Decorator[]; | ||
createDecoratorObjectLiteralExpr(node: ts.MethodDeclaration, typeChecker: ts.TypeChecker, existingProperties: ts.NodeArray<ts.PropertyAssignment>, hostFilename: string): ts.ObjectLiteralExpression; | ||
@@ -10,0 +10,0 @@ createTypePropertyAssignment(node: ts.MethodDeclaration, typeChecker: ts.TypeChecker, existingProperties: ts.NodeArray<ts.PropertyAssignment>, hostFilename: string): ts.PropertyAssignment; |
@@ -33,3 +33,3 @@ "use strict"; | ||
node.decorators = Object.assign([ | ||
...this.createApiOperationDecorator(node, nodeArray, options, sourceFile), | ||
...this.createApiOperationDecorator(node, nodeArray, options, sourceFile, typeChecker), | ||
...nodeArray, | ||
@@ -42,3 +42,3 @@ ts.createDecorator(ts.createCall(ts.createIdentifier(`${plugin_constants_1.OPENAPI_NAMESPACE}.${decorators_1.ApiResponse.name}`), undefined, [ | ||
} | ||
createApiOperationDecorator(node, nodeArray, options, sourceFile) { | ||
createApiOperationDecorator(node, nodeArray, options, sourceFile, typeChecker) { | ||
if (!options.introspectComments) { | ||
@@ -57,3 +57,3 @@ return []; | ||
!plugin_utils_1.hasPropertyKey(keyToGenerate, apiOperationExprProperties)) { | ||
const [extractedComments] = ast_utils_1.getMainCommentAndExamplesOfNode(node, sourceFile); | ||
const [extractedComments] = ast_utils_1.getMainCommentAndExamplesOfNode(node, sourceFile, typeChecker); | ||
if (!extractedComments) { | ||
@@ -60,0 +60,0 @@ return []; |
@@ -16,4 +16,4 @@ import * as ts from 'typescript'; | ||
addClassMetadata(node: ts.PropertyDeclaration, objectLiteral: ts.ObjectLiteralExpression, sourceFile: ts.SourceFile, metadata: ClassMetadata): void; | ||
createDescriptionAndExamplePropertyAssigments(node: ts.PropertyDeclaration | ts.PropertySignature, existingProperties?: ts.NodeArray<ts.PropertyAssignment>, options?: PluginOptions, sourceFile?: ts.SourceFile): ts.PropertyAssignment[]; | ||
createDescriptionAndExamplePropertyAssigments(node: ts.PropertyDeclaration | ts.PropertySignature, typeChecker: ts.TypeChecker, existingProperties?: ts.NodeArray<ts.PropertyAssignment>, options?: PluginOptions, sourceFile?: ts.SourceFile): ts.PropertyAssignment[]; | ||
} | ||
export {}; |
@@ -63,3 +63,3 @@ "use strict"; | ||
...this.createTypePropertyAssignments(node.type, typeChecker, existingProperties, hostFilename), | ||
...this.createDescriptionAndExamplePropertyAssigments(node, existingProperties, options, sourceFile), | ||
...this.createDescriptionAndExamplePropertyAssigments(node, typeChecker, existingProperties, options, sourceFile), | ||
this.createDefaultPropertyAssignment(node, existingProperties), | ||
@@ -207,3 +207,3 @@ this.createEnumPropertyAssignment(node, typeChecker, existingProperties, hostFilename) | ||
} | ||
createDescriptionAndExamplePropertyAssigments(node, existingProperties = ts.createNodeArray(), options = {}, sourceFile) { | ||
createDescriptionAndExamplePropertyAssigments(node, typeChecker, existingProperties = ts.createNodeArray(), options = {}, sourceFile) { | ||
if (!options.introspectComments || !sourceFile) { | ||
@@ -213,3 +213,3 @@ return []; | ||
const propertyAssignments = []; | ||
const [comments, examples] = ast_utils_1.getMainCommentAndExamplesOfNode(node, sourceFile, true); | ||
const [comments, examples] = ast_utils_1.getMainCommentAndExamplesOfNode(node, sourceFile, typeChecker, true); | ||
const keyOfComment = options.dtoKeyOfComment; | ||
@@ -216,0 +216,0 @@ if (!plugin_utils_1.hasPropertyKey(keyOfComment, existingProperties) && comments) { |
{ | ||
"name": "@nestjs/swagger", | ||
"version": "4.7.5", | ||
"version": "4.7.6", | ||
"description": "Nest - modern, fast, powerful node.js web framework (@swagger)", | ||
@@ -30,28 +30,28 @@ "author": "Kamil Mysliwiec", | ||
"@commitlint/config-angular": "11.0.0", | ||
"@nestjs/common": "7.5.2", | ||
"@nestjs/core": "7.5.2", | ||
"@nestjs/platform-express": "7.5.2", | ||
"@nestjs/platform-fastify": "7.5.3", | ||
"@types/jest": "26.0.15", | ||
"@nestjs/common": "7.6.1", | ||
"@nestjs/core": "7.6.1", | ||
"@nestjs/platform-express": "7.6.1", | ||
"@nestjs/platform-fastify": "7.6.1", | ||
"@types/jest": "26.0.19", | ||
"@types/lodash": "4.14.165", | ||
"@types/node": "11.15.0", | ||
"@typescript-eslint/eslint-plugin": "4.8.0", | ||
"@typescript-eslint/parser": "4.8.0", | ||
"@typescript-eslint/eslint-plugin": "4.9.1", | ||
"@typescript-eslint/parser": "4.9.1", | ||
"class-transformer": "0.3.1", | ||
"class-validator": "0.12.2", | ||
"eslint": "7.13.0", | ||
"eslint-config-prettier": "6.15.0", | ||
"eslint": "7.15.0", | ||
"eslint-config-prettier": "7.0.0", | ||
"eslint-plugin-import": "2.22.1", | ||
"express": "4.17.1", | ||
"fastify-swagger": "3.5.0", | ||
"husky": "4.3.0", | ||
"husky": "4.3.6", | ||
"jest": "26.6.3", | ||
"lint-staged": "10.5.1", | ||
"prettier": "2.1.2", | ||
"lint-staged": "10.5.3", | ||
"prettier": "2.2.1", | ||
"reflect-metadata": "0.1.13", | ||
"release-it": "14.2.1", | ||
"release-it": "14.2.2", | ||
"swagger-parser": "10.0.2", | ||
"swagger-ui-express": "4.1.4", | ||
"swagger-ui-express": "4.1.5", | ||
"ts-jest": "26.4.4", | ||
"typescript": "4.0.5" | ||
"typescript": "4.1.3" | ||
}, | ||
@@ -58,0 +58,0 @@ "peerDependencies": { |
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
215366
4403