From d32239e53ab39234e459cc84657c4c90e93edaa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E7=A7=8B=E6=97=AD?= Date: Thu, 16 Feb 2023 16:41:34 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20add=20addBearerAuth=20swagger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/auth/auth.controller.ts | 3 ++- src/main.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index 7460d99..9feee0d 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -1,7 +1,7 @@ import { Body, Controller, Get, Post } from '@nestjs/common' import { AuthService } from './auth.service' import { CreateUserDto } from 'src/users/dto/create-user.dto' -import { ApiTags } from '@nestjs/swagger' +import { ApiTags, ApiBearerAuth } from '@nestjs/swagger' import { LoginInputDto } from './dto/login-input.dto' import { UserEntity } from 'src/users/entities/user.entity' import { User } from 'src/common/decorators/user.decorator' @@ -24,6 +24,7 @@ export class AuthController { return this.authService.login(user.email, user.password) } + @ApiBearerAuth() @Get('api/profile') async getUserInfo(@User() user: UserEntity) { return user diff --git a/src/main.ts b/src/main.ts index 0d212e0..80a79c3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -21,6 +21,7 @@ async function bootstrap() { // Swagger Api const options = new DocumentBuilder() + .addBearerAuth() .setTitle('Nest Project') .setDescription('The Nest-Project API description') .setVersion('1.0')