Skip to content

Commit

Permalink
feat : swagger 문서에 api tag를 통해 api 그룹화 #35
Browse files Browse the repository at this point in the history
Co-authored-by: GeunH <[email protected]>
  • Loading branch information
LeeTH916 and GeunH committed Nov 28, 2023
1 parent eade072 commit e9a0fda
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions be/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Expand Down
1 change: 0 additions & 1 deletion be/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions be/src/restaurant/restaurant.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ import {
ApiParam,
ApiQuery,
ApiResponse,
ApiTags,
} from "@nestjs/swagger";
import { RestaurantService } from "./restaurant.service";
import { SearchInfoDto } from "./dto/seachInfo.dto";
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) {}
Expand Down
2 changes: 1 addition & 1 deletion be/src/restaurant/restaurant.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class RestaurantRepository extends Repository<RestaurantInfoEntity> {
.where("restaurant.name LIKE :partialName")
.setParameters({
partialName: `%${searchInfoDto.partialName}%`,
userId: tokenInfo.id,
userId: tokenInfo.id,
})
.limit(15)
.getRawMany();
Expand Down
22 changes: 22 additions & 0 deletions be/src/user/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
ApiParam,
ApiQuery,
ApiResponse,
ApiTags,
} from "@nestjs/swagger";
import { UserInfoDto } from "./dto/userInfo.dto";
import { UserService } from "./user.service";
Expand All @@ -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()
Expand All @@ -44,6 +46,7 @@ export class UserController {
return await this.userService.getMypageUserDetailInfo(tokenInfo);
}

@ApiTags("Mypage")
@Get("/details")
@UseGuards(AuthGuard("jwt"))
@ApiBearerAuth()
Expand All @@ -55,6 +58,7 @@ export class UserController {
return await this.userService.getMypageUserInfo(tokenInfo);
}

@ApiTags("Follow/Following")
@Get(":nickName/details")
@UseGuards(AuthGuard("jwt"))
@ApiBearerAuth()
Expand All @@ -72,6 +76,7 @@ export class UserController {
return await this.userService.getMypageTargetUserInfo(tokenInfo, nickName);
}

@ApiTags("Follow/Following")
@Get("/autocomplete/:partialUsername")
@UseGuards(AuthGuard("jwt"))
@ApiBearerAuth()
Expand All @@ -86,6 +91,7 @@ export class UserController {
return await this.userService.searchTargetUser(tokenInfo, partialUsername);
}

@ApiTags("Signup", "Mypage")
@Get("nickname/:nickname/exists")
@ApiParam({
name: "nickname",
Expand All @@ -102,6 +108,7 @@ export class UserController {
return await this.userService.getNickNameAvailability(nickname);
}

@ApiTags("Signup", "Mypage")
@Get("email/:email/exists")
@ApiParam({
name: "email",
Expand All @@ -116,6 +123,7 @@ export class UserController {
return await this.userService.getEmailAvailability(email);
}

@ApiTags("Mypage", "Home")
@Get("/restaurant")
@UseGuards(AuthGuard("jwt"))
@ApiBearerAuth()
Expand Down Expand Up @@ -152,6 +160,7 @@ export class UserController {
);
}

@ApiTags("Mypage")
@Get("/wish-restaurant")
@UseGuards(AuthGuard("jwt"))
@ApiBearerAuth()
Expand All @@ -162,6 +171,7 @@ export class UserController {
return await this.userService.getMyWishRestaurantListInfo(tokenInfo);
}

@ApiTags("Follow/Following", "Home")
@Get("follow-list")
@UseGuards(AuthGuard("jwt"))
@ApiBearerAuth()
Expand All @@ -173,6 +183,7 @@ export class UserController {
return await this.userService.getMyFollowListInfo(tokenInfo);
}

@ApiTags("Follow/Following")
@Get("followed-list")
@UseGuards(AuthGuard("jwt"))
@ApiBearerAuth()
Expand All @@ -184,6 +195,7 @@ export class UserController {
return await this.userService.getMyFollowerListInfo(tokenInfo);
}

@ApiTags("Follow/Following")
@Get("recommended")
@UseGuards(AuthGuard("jwt"))
@ApiBearerAuth()
Expand All @@ -194,6 +206,7 @@ export class UserController {
return await this.userService.getRecommendUserListInfo(tokenInfo);
}

@ApiTags("Signup")
@Post()
@ApiOperation({ summary: "유저 회원가입" })
@ApiResponse({ status: 200, description: "회원가입 성공" })
Expand All @@ -203,6 +216,7 @@ export class UserController {
return await this.userService.signup(userInfoDto);
}

@ApiTags("Follow/Following")
@Post("follow-list/:nickName")
@ApiParam({
name: "nickName",
Expand All @@ -224,6 +238,7 @@ export class UserController {
return await this.userService.followUser(tokenInfo, nickName);
}

@ApiTags("RestaurantList")
@Post("/restaurant/:restaurantid")
@UseGuards(AuthGuard("jwt"))
@ApiBearerAuth()
Expand All @@ -249,6 +264,7 @@ export class UserController {
);
}

@ApiTags("RestaurantList")
@Delete("/restaurant/:restaurantid")
@UseGuards(AuthGuard("jwt"))
@ApiBearerAuth()
Expand All @@ -266,6 +282,7 @@ export class UserController {
);
}

@ApiTags("WishRestaurantList")
@Post("/wish-restaurant/:restaurantid")
@UseGuards(AuthGuard("jwt"))
@ApiBearerAuth()
Expand All @@ -289,6 +306,7 @@ export class UserController {
);
}

@ApiTags("WishRestaurantList")
@Delete("/wish-restaurant/:restaurantid")
@UseGuards(AuthGuard("jwt"))
@ApiBearerAuth()
Expand All @@ -306,6 +324,7 @@ export class UserController {
);
}

@ApiTags("Mypage")
@Post("logout")
@UseGuards(AuthGuard("jwt"))
@ApiBearerAuth()
Expand All @@ -316,6 +335,7 @@ export class UserController {
return await this.userService.logout(tokenInfo);
}

@ApiTags("Mypage")
@Delete()
@UseGuards(AuthGuard("jwt"))
@ApiBearerAuth()
Expand All @@ -328,6 +348,7 @@ export class UserController {
return await this.userService.deleteUserAccount(tokenInfo);
}

@ApiTags("Follow/Following")
@Delete("follow-list/:nickName")
@ApiParam({
name: "nickName",
Expand All @@ -349,6 +370,7 @@ export class UserController {
return await this.userService.unfollowUser(tokenInfo, nickName);
}

@ApiTags("Mypage")
@Put()
@UseGuards(AuthGuard("jwt"))
@ApiBearerAuth()
Expand Down

0 comments on commit e9a0fda

Please sign in to comment.