Swagger: @ApiBearerAuth() does not work on Method level

Created on 5 Apr 2018  路  13Comments  路  Source: nestjs/swagger

image
image
As title said, the @ApiBearerAuth() decorator does not work properly on method level. It does work correctly on Controller level. The documentations states that the decorator can work on either Method or Controller level. I was just wondering if this's a bug or I didn't implement it correctly.

image
Worked on Controller level

Most helpful comment

I am having this issue again, using @nestjs/common 5.0.0, @nestjs/core 5.0.0 and @nestjs/swagger 2.0.0

All 13 comments

I also encountered the same problem

reverted back to v1.1.4 and it seems works at this version.

Thanks but I do not consider reverting to an older version a solution. I need the enum from the current versions as well.

Same problem for me

Fixed due to #79 and published as a v1.3.0 already.

I am having this issue again, using @nestjs/common 5.0.0, @nestjs/core 5.0.0 and @nestjs/swagger 2.0.0

I have it at controller level and it's not working for me

@ApiBearerAuth() @UseGuards(JwtAuthGuard) export class AdminController {

"@nestjs/core": "^5.1.0",
"@nestjs/swagger": "^2.5.1",

@nartc
I solved it by add this line to main.ts (or wherever you register nestjs-swagger)
const options = new DocumentBuilder()
.addBearerAuth()

image

But in your controller/method you also need to define
@ApiBearerAuth()

Hope this help !!

@trileou thanks but this was a really old issue and it got addressed (fixed) a couple major versions back.

still not working on current version

still not working on current version

Yeah, I was facing this problem, and I just figured out the bug.

It was introduced in an erroneous commit at https://github.com/nestjs/swagger/commit/916be52418600c3ec5fa984d0ae323e004f43cbd#diff-b0ad145a500347ad4d7404490dbce088L24

I'll file a new issue (since this is old and closed), and make a PR to fix it.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ivashog picture ivashog  路  3Comments

kalaivanan-muthusamy picture kalaivanan-muthusamy  路  4Comments

itslenny picture itslenny  路  3Comments

alisherks picture alisherks  路  4Comments

yuval-hazaz picture yuval-hazaz  路  3Comments