Skip to content

Commit 774a3b4

Browse files
committed
docs : 토론글 관련 swagger 업데이트
1 parent 32f243a commit 774a3b4

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

src/main/java/org/ezcode/codetest/application/community/dto/response/DiscussionResponse.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import io.swagger.v3.oas.annotations.media.Schema;
1313

14-
@Schema(name = "DiscussionResponse", description = "Discussion 조회 응답 DTO")
14+
@Schema(name = "DiscussionResponse", description = "Discussion 응답 DTO, 목록 조회 시에만 추천 수, 비추천 수 등의 데이터가 포함됨")
1515
public record DiscussionResponse(
1616

1717
@Schema(description = "Discussion 고유 ID", example = "123", requiredMode = REQUIRED)
@@ -26,14 +26,19 @@ public record DiscussionResponse(
2626
@Schema(description = "토론 내용", example = "이 문제는 이렇게 풀 수 있습니다...", requiredMode = REQUIRED)
2727
String content,
2828

29+
@Schema(description = "생성 일시", example = "2025-06-25T14:30:00", requiredMode = REQUIRED)
2930
LocalDateTime createdAt,
3031

32+
@Schema(description = "총 추천 수 (upvote)", example = "10")
3133
Long upvoteCount,
3234

35+
@Schema(description = "총 비추천 수 (downvote)", example = "2")
3336
Long downvoteCount,
3437

38+
@Schema(description = "총 댓글 수", example = "5")
3539
Long replyCount,
3640

41+
@Schema(description = "현재 사용자의 추천 상태 (UP, DOWN, NONE)", example = "UP")
3742
VoteType voteStatus
3843

3944
) {

src/main/java/org/ezcode/codetest/presentation/community/DiscussionController.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,29 @@
2121
import org.springframework.web.bind.annotation.RequestParam;
2222
import org.springframework.web.bind.annotation.RestController;
2323

24+
import io.swagger.v3.oas.annotations.Operation;
25+
import io.swagger.v3.oas.annotations.Parameter;
26+
import io.swagger.v3.oas.annotations.responses.ApiResponse;
27+
import io.swagger.v3.oas.annotations.tags.Tag;
2428
import jakarta.validation.Valid;
2529
import lombok.RequiredArgsConstructor;
2630

2731
@RestController
2832
@RequestMapping("/api/problems/{problemId}/discussions")
33+
@Tag(name = "Discussions", description = "문제별 토론글 관리 API")
2934
@RequiredArgsConstructor
3035
public class DiscussionController {
3136

3237
private final DiscussionService discussionService;
3338

39+
@Operation(
40+
summary = "토론 생성",
41+
description = "주어진 문제 ID에 새로운 Discussion을 생성합니다.",
42+
parameters = {
43+
@Parameter(name = "problemId", description = "문제 ID", required = true)
44+
}
45+
)
46+
@ApiResponse(responseCode = "201", description = "생성된 DiscussionResponse 반환")
3447
@PostMapping
3548
public ResponseEntity<DiscussionResponse> createDiscussion(
3649
@PathVariable Long problemId,
@@ -42,6 +55,15 @@ public ResponseEntity<DiscussionResponse> createDiscussion(
4255
.body(discussionService.createDiscussion(problemId, request, authUser.getId()));
4356
}
4457

58+
@Operation(
59+
summary = "토론 목록 조회",
60+
description = "문제별 Discussion 목록을 정렬(sortBy) 및 페이징(pageable)하여 조회합니다. 로그인하지 않은 상태로도 조회할 수 있습니다.",
61+
parameters = {
62+
@Parameter(name = "problemId", description = "문제 ID", required = true),
63+
@Parameter(name = "sortBy", description = "정렬 기준 (best, upvote, latest), best: upvote-downvote 순으로 정렬", example = "best", required = false)
64+
}
65+
)
66+
@ApiResponse(responseCode = "200", description = "토론 목록 조회 성공")
4567
@GetMapping
4668
public ResponseEntity<Page<DiscussionResponse>> getDiscussions(
4769
@PathVariable Long problemId,
@@ -57,6 +79,15 @@ public ResponseEntity<Page<DiscussionResponse>> getDiscussions(
5779
.body(discussionService.getDiscussions(problemId, sortBy, currentUserId, pageable));
5880
}
5981

82+
@Operation(
83+
summary = "토론 수정",
84+
description = "특정 Discussion을 수정합니다.",
85+
parameters = {
86+
@Parameter(name = "problemId", description = "문제 ID", required = true),
87+
@Parameter(name = "discussionId", description = "토론 ID", required = true)
88+
}
89+
)
90+
@ApiResponse(responseCode = "200", description = "수정된 DiscussionResponse 반환")
6091
@PutMapping("/{discussionId}")
6192
public ResponseEntity<DiscussionResponse> modifyDiscussion(
6293
@PathVariable Long problemId,
@@ -69,6 +100,15 @@ public ResponseEntity<DiscussionResponse> modifyDiscussion(
69100
.body(discussionService.modifyDiscussion(problemId, discussionId, request, authUser.getId()));
70101
}
71102

103+
@Operation(
104+
summary = "토론 삭제",
105+
description = "특정 Discussion을 삭제합니다.",
106+
parameters = {
107+
@Parameter(name = "problemId", description = "문제 ID", required = true),
108+
@Parameter(name = "discussionId", description = "토론 ID", required = true)
109+
}
110+
)
111+
@ApiResponse(responseCode = "200", description = "삭제 성공")
72112
@DeleteMapping("/{discussionId}")
73113
public ResponseEntity<Void> removeDiscussion(
74114
@PathVariable Long problemId,

0 commit comments

Comments
 (0)