📝 add addBearerAuth swagger

This commit is contained in:
秦秋旭 2023-02-16 16:41:34 +08:00
parent 93127d2bd6
commit d32239e53a
2 changed files with 3 additions and 1 deletions

View File

@ -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

View File

@ -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')