Swagger: Add generality security decorator instead of @ApiBearerAuth() @ApiOAuth2Auth()

Created on 19 Sep 2018  路  10Comments  路  Source: nestjs/swagger

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior


We are trying to migrate our old express & swagger application to Nest.
The app have security parameter for own rule that is not bearer and oauth2.
But there are only @ApiBearerAuth() @ApiOAuth2Auth().

Expected behavior


I guess we can use a generality security decorator. Example:

@ApiSecurity(securityDefinitionName)
@Get()
async findAll() {



Environment


Nest version: 5.3.7
@nestjs/swagger: 2.5.1

enhancement next

Most helpful comment

4.0.0 has been published

All 10 comments

Could you share your definition example?

@kamilmysliwiec looks like it is just a BearerAuth with a custom name. Once this is solved (https://github.com/nestjs/swagger/issues/130) then you can decorate your SessionID Auth with NestJS @ktanakaj

I haven't had time to look into the #130 solution but will do this weekend.

Oh, great! I'll try to use BearerAuth with a custom name after #130 is solved. Thanks a lot!

@ktanakaj PR has been opened. Hopefully it gets reviewed and merged soon

Added in the next version (to install run npm i @nestjs/swagger@next). Note: remember to update @nestjs/common, @nestjs/core and typescript as well to ensure that you're using the latest versions.

Steps to migrate: https://github.com/nestjs/swagger/pull/355#issuecomment-547925879

I was able to add my security definition by new @ApiSecurity tag on @nestjs/swagger@next. Thank you so much :+1:

4.0.0 has been published

Are there some release notes somewhere we can read? My project is on 3.1.x so I don't have access to @ApiSecurity - but it would be nice to have release notes so I can get a general flavor of how compatible 4.x is with 3.x.

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