Skip to content

Commit

Permalink
Merge pull request #2154 from bangbang93/master
Browse files Browse the repository at this point in the history
fix(plugin): empty comment do not emit @ApiOperation decorator
  • Loading branch information
kamilmysliwiec committed Feb 6, 2023
2 parents 4f786b1 + f4e35f2 commit ce1712c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/plugin/visitors/controller-class.visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ export class ControllerClassVisitor extends AbstractFileVisitor {
(apiOperationExpr.properties as ts.NodeArray<ts.PropertyAssignment>);

const extractedComments = getMainCommentOfNode(node, sourceFile);
if (!extractedComments) {
return [];
}
const tags = getTsDocTagsOfNode(node, sourceFile, typeChecker);

const properties = [
Expand Down
10 changes: 10 additions & 0 deletions test/plugin/fixtures/app.controller-without-modifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ export class AppController {
@Get()
@HttpCode(HttpStatus.NO_CONTENT)
findAll(): Promise<Cat[]> {}
@Get()
@HttpCode(HttpStatus.NO_CONTENT)
noComment() {}
}`;

export const appControllerWithoutModifiersTextTranspiled = `\"use strict\";
Expand Down Expand Up @@ -102,6 +106,7 @@ let AppController = class AppController {
* @memberof AppController
*/
findAll() { }
noComment() { }
};
__decorate([
openapi.ApiOperation({ summary: "create a Cat" }),
Expand Down Expand Up @@ -129,6 +134,11 @@ __decorate([
HttpCode(common_1.HttpStatus.NO_CONTENT),
openapi.ApiResponse({ status: common_1.HttpStatus.NO_CONTENT, type: [Cat] })
], AppController.prototype, \"findAll\", null);
__decorate([
Get(),
HttpCode(common_1.HttpStatus.NO_CONTENT),
openapi.ApiResponse({ status: common_1.HttpStatus.NO_CONTENT })
], AppController.prototype, \"noComment\", null);
AppController = __decorate([
(0, common_1.Controller)('cats')
], AppController);
Expand Down

0 comments on commit ce1712c

Please sign in to comment.