From e9a0fda6cdb48b66e8a5c9f9f31872cf7716189b Mon Sep 17 00:00:00 2001 From: LeeTH916 Date: Tue, 28 Nov 2023 17:43:12 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20swagger=20=EB=AC=B8=EC=84=9C?= =?UTF-8?q?=EC=97=90=20api=20tag=EB=A5=BC=20=ED=86=B5=ED=95=B4=20api=20?= =?UTF-8?q?=EA=B7=B8=EB=A3=B9=ED=99=94=20#35?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: GeunH --- be/src/auth/auth.controller.ts | 1 + be/src/main.ts | 1 - be/src/restaurant/restaurant.controller.ts | 2 ++ be/src/restaurant/restaurant.repository.ts | 2 +- be/src/user/user.controller.ts | 22 ++++++++++++++++++++++ 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/be/src/auth/auth.controller.ts b/be/src/auth/auth.controller.ts index 268af057..bbf98afc 100644 --- a/be/src/auth/auth.controller.ts +++ b/be/src/auth/auth.controller.ts @@ -16,6 +16,7 @@ import { } from "@nestjs/swagger"; import { RefreshTokenDto } from "./dto/refreshToken.dto"; +@ApiTags("Authentication") @Controller("auth") export class AuthController { constructor(private authService: AuthService) {} diff --git a/be/src/main.ts b/be/src/main.ts index d82366b4..9cb01427 100644 --- a/be/src/main.ts +++ b/be/src/main.ts @@ -15,7 +15,6 @@ async function bootstrap() { .setDescription("The example API description") .setVersion("1.0") .addBearerAuth() - .addTag("example") .build(); const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup("api", app, document); diff --git a/be/src/restaurant/restaurant.controller.ts b/be/src/restaurant/restaurant.controller.ts index 47fdf5ce..c3a918ea 100644 --- a/be/src/restaurant/restaurant.controller.ts +++ b/be/src/restaurant/restaurant.controller.ts @@ -14,6 +14,7 @@ import { ApiParam, ApiQuery, ApiResponse, + ApiTags, } from "@nestjs/swagger"; import { RestaurantService } from "./restaurant.service"; import { SearchInfoDto } from "./dto/seachInfo.dto"; @@ -21,6 +22,7 @@ import { FilterInfoDto } from "./dto/filterInfo.dto"; import { GetUser, TokenInfo } from "src/user/user.decorator"; import { LocationDto } from "./dto/location.dto"; +@ApiTags("Home") @Controller("restaurant") export class RestaurantController { constructor(private restaurantService: RestaurantService) {} diff --git a/be/src/restaurant/restaurant.repository.ts b/be/src/restaurant/restaurant.repository.ts index 1bb04cac..f050e383 100644 --- a/be/src/restaurant/restaurant.repository.ts +++ b/be/src/restaurant/restaurant.repository.ts @@ -94,7 +94,7 @@ export class RestaurantRepository extends Repository { .where("restaurant.name LIKE :partialName") .setParameters({ partialName: `%${searchInfoDto.partialName}%`, - userId: tokenInfo.id, + userId: tokenInfo.id, }) .limit(15) .getRawMany(); diff --git a/be/src/user/user.controller.ts b/be/src/user/user.controller.ts index fdac72ae..56276746 100644 --- a/be/src/user/user.controller.ts +++ b/be/src/user/user.controller.ts @@ -17,6 +17,7 @@ import { ApiParam, ApiQuery, ApiResponse, + ApiTags, } from "@nestjs/swagger"; import { UserInfoDto } from "./dto/userInfo.dto"; import { UserService } from "./user.service"; @@ -30,6 +31,7 @@ import { ReviewInfoDto } from "src/review/dto/reviewInfo.dto"; export class UserController { constructor(private userService: UserService) {} + @ApiTags("Mypage") @Get() @UseGuards(AuthGuard("jwt")) @ApiBearerAuth() @@ -44,6 +46,7 @@ export class UserController { return await this.userService.getMypageUserDetailInfo(tokenInfo); } + @ApiTags("Mypage") @Get("/details") @UseGuards(AuthGuard("jwt")) @ApiBearerAuth() @@ -55,6 +58,7 @@ export class UserController { return await this.userService.getMypageUserInfo(tokenInfo); } + @ApiTags("Follow/Following") @Get(":nickName/details") @UseGuards(AuthGuard("jwt")) @ApiBearerAuth() @@ -72,6 +76,7 @@ export class UserController { return await this.userService.getMypageTargetUserInfo(tokenInfo, nickName); } + @ApiTags("Follow/Following") @Get("/autocomplete/:partialUsername") @UseGuards(AuthGuard("jwt")) @ApiBearerAuth() @@ -86,6 +91,7 @@ export class UserController { return await this.userService.searchTargetUser(tokenInfo, partialUsername); } + @ApiTags("Signup", "Mypage") @Get("nickname/:nickname/exists") @ApiParam({ name: "nickname", @@ -102,6 +108,7 @@ export class UserController { return await this.userService.getNickNameAvailability(nickname); } + @ApiTags("Signup", "Mypage") @Get("email/:email/exists") @ApiParam({ name: "email", @@ -116,6 +123,7 @@ export class UserController { return await this.userService.getEmailAvailability(email); } + @ApiTags("Mypage", "Home") @Get("/restaurant") @UseGuards(AuthGuard("jwt")) @ApiBearerAuth() @@ -152,6 +160,7 @@ export class UserController { ); } + @ApiTags("Mypage") @Get("/wish-restaurant") @UseGuards(AuthGuard("jwt")) @ApiBearerAuth() @@ -162,6 +171,7 @@ export class UserController { return await this.userService.getMyWishRestaurantListInfo(tokenInfo); } + @ApiTags("Follow/Following", "Home") @Get("follow-list") @UseGuards(AuthGuard("jwt")) @ApiBearerAuth() @@ -173,6 +183,7 @@ export class UserController { return await this.userService.getMyFollowListInfo(tokenInfo); } + @ApiTags("Follow/Following") @Get("followed-list") @UseGuards(AuthGuard("jwt")) @ApiBearerAuth() @@ -184,6 +195,7 @@ export class UserController { return await this.userService.getMyFollowerListInfo(tokenInfo); } + @ApiTags("Follow/Following") @Get("recommended") @UseGuards(AuthGuard("jwt")) @ApiBearerAuth() @@ -194,6 +206,7 @@ export class UserController { return await this.userService.getRecommendUserListInfo(tokenInfo); } + @ApiTags("Signup") @Post() @ApiOperation({ summary: "유저 회원가입" }) @ApiResponse({ status: 200, description: "회원가입 성공" }) @@ -203,6 +216,7 @@ export class UserController { return await this.userService.signup(userInfoDto); } + @ApiTags("Follow/Following") @Post("follow-list/:nickName") @ApiParam({ name: "nickName", @@ -224,6 +238,7 @@ export class UserController { return await this.userService.followUser(tokenInfo, nickName); } + @ApiTags("RestaurantList") @Post("/restaurant/:restaurantid") @UseGuards(AuthGuard("jwt")) @ApiBearerAuth() @@ -249,6 +264,7 @@ export class UserController { ); } + @ApiTags("RestaurantList") @Delete("/restaurant/:restaurantid") @UseGuards(AuthGuard("jwt")) @ApiBearerAuth() @@ -266,6 +282,7 @@ export class UserController { ); } + @ApiTags("WishRestaurantList") @Post("/wish-restaurant/:restaurantid") @UseGuards(AuthGuard("jwt")) @ApiBearerAuth() @@ -289,6 +306,7 @@ export class UserController { ); } + @ApiTags("WishRestaurantList") @Delete("/wish-restaurant/:restaurantid") @UseGuards(AuthGuard("jwt")) @ApiBearerAuth() @@ -306,6 +324,7 @@ export class UserController { ); } + @ApiTags("Mypage") @Post("logout") @UseGuards(AuthGuard("jwt")) @ApiBearerAuth() @@ -316,6 +335,7 @@ export class UserController { return await this.userService.logout(tokenInfo); } + @ApiTags("Mypage") @Delete() @UseGuards(AuthGuard("jwt")) @ApiBearerAuth() @@ -328,6 +348,7 @@ export class UserController { return await this.userService.deleteUserAccount(tokenInfo); } + @ApiTags("Follow/Following") @Delete("follow-list/:nickName") @ApiParam({ name: "nickName", @@ -349,6 +370,7 @@ export class UserController { return await this.userService.unfollowUser(tokenInfo, nickName); } + @ApiTags("Mypage") @Put() @UseGuards(AuthGuard("jwt")) @ApiBearerAuth()