'Nestjs swagger authorizations with JWT Token returning unauthorised even after passing token

I am using JWT strategy for authorization. I'm using the token to validate the user in all controllers. And I've successfully managed to get the desired response in postman after setting the token in Auth Bearer Token. But After Setting the token in swagger as given bellow enter image description here

I'm getting an Unauthorized response. The reason must be, that somehow inside the swagger my controllers are not getting access to the token. Following is the code for swagger documentation.

export function createDocument(app:INestApplication): OpenAPIObject{
const builder = new DocumentBuilder()
    .setTitle(SWAGGER_CONFIG.title)
    .setVersion(SWAGGER_CONFIG.version)
    .addBearerAuth({
        type:"http",
        scheme:'bearer',
        bearerFormat:'JWT',
    
        } ,'access-token')
                        
const options = builder.build();
return SwaggerModule.createDocument(app, options);

}

Following is a example of a controller

@ApiTags("Users")
@Controller('users')
export class UserController {
    @UseGuards(JwtAuthGuard)
    @Get('me')
    @ApiOkResponse({ description:"Successfully returned response"})
    @ApiForbiddenResponse({ description: "Forbidden" })
    async profile(@Req() request, @Res() response){
    some code}

following is a example of one of the swagger route enter image description here

enter image description here

please let me know where am I getting it wrong any help would a appreciated



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source