Skip to content

Commit 56d2cf6

Browse files
committed
Docs: Swagger 문서 작성
1 parent f4bd417 commit 56d2cf6

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

src/main/java/com/back/domain/board/controller/CommentControllerDocs.java

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.back.domain.board.controller;
22

3+
import com.back.domain.board.dto.CommentListResponse;
34
import com.back.domain.board.dto.CommentRequest;
45
import com.back.domain.board.dto.CommentResponse;
6+
import com.back.domain.board.dto.PageResponse;
57
import com.back.global.common.dto.RsData;
68
import com.back.global.security.user.CustomUserDetails;
79
import io.swagger.v3.oas.annotations.Operation;
@@ -10,6 +12,7 @@
1012
import io.swagger.v3.oas.annotations.responses.ApiResponse;
1113
import io.swagger.v3.oas.annotations.responses.ApiResponses;
1214
import io.swagger.v3.oas.annotations.tags.Tag;
15+
import org.springframework.data.domain.Pageable;
1316
import org.springframework.http.ResponseEntity;
1417
import org.springframework.security.core.annotation.AuthenticationPrincipal;
1518
import org.springframework.web.bind.annotation.*;
@@ -142,6 +145,115 @@ ResponseEntity<RsData<CommentResponse>> createComment(
142145
@AuthenticationPrincipal CustomUserDetails user
143146
);
144147

148+
@Operation(
149+
summary = "댓글 목록 조회",
150+
description = "특정 게시글에 달린 댓글 목록을 조회합니다. " +
151+
"부모 댓글 기준으로 페이징되며, 각 댓글의 대댓글(children) 목록이 함께 포함됩니다."
152+
)
153+
@ApiResponses({
154+
@ApiResponse(
155+
responseCode = "200",
156+
description = "댓글 목록 조회 성공",
157+
content = @Content(
158+
mediaType = "application/json",
159+
examples = @ExampleObject(value = """
160+
{
161+
"success": true,
162+
"code": "SUCCESS_200",
163+
"message": "댓글 목록이 조회되었습니다.",
164+
"data": {
165+
"content": [
166+
{
167+
"commentId": 1,
168+
"postId": 101,
169+
"parentId": null,
170+
"author": {
171+
"id": 5,
172+
"nickname": "홍길동"
173+
},
174+
"content": "부모 댓글",
175+
"likeCount": 2,
176+
"createdAt": "2025-09-22T11:30:00",
177+
"updatedAt": "2025-09-22T11:30:00",
178+
"children": [
179+
{
180+
"commentId": 2,
181+
"postId": 101,
182+
"parentId": 1,
183+
"author": {
184+
"id": 5,
185+
"nickname": "홍길동"
186+
},
187+
"content": "자식 댓글",
188+
"likeCount": 0,
189+
"createdAt": "2025-09-22T11:35:00",
190+
"updatedAt": "2025-09-22T11:35:00",
191+
"children": []
192+
}
193+
]
194+
}
195+
],
196+
"pageNumber": 0,
197+
"pageSize": 10,
198+
"totalElements": 1,
199+
"totalPages": 1,
200+
"last": true
201+
}
202+
}
203+
""")
204+
)
205+
),
206+
@ApiResponse(
207+
responseCode = "400",
208+
description = "잘못된 요청 (파라미터 오류)",
209+
content = @Content(
210+
mediaType = "application/json",
211+
examples = @ExampleObject(value = """
212+
{
213+
"success": false,
214+
"code": "COMMON_400",
215+
"message": "잘못된 요청입니다.",
216+
"data": null
217+
}
218+
""")
219+
)
220+
),
221+
@ApiResponse(
222+
responseCode = "404",
223+
description = "존재하지 않는 게시글",
224+
content = @Content(
225+
mediaType = "application/json",
226+
examples = @ExampleObject(value = """
227+
{
228+
"success": false,
229+
"code": "POST_001",
230+
"message": "존재하지 않는 게시글입니다.",
231+
"data": null
232+
}
233+
""")
234+
)
235+
),
236+
@ApiResponse(
237+
responseCode = "500",
238+
description = "서버 내부 오류",
239+
content = @Content(
240+
mediaType = "application/json",
241+
examples = @ExampleObject(value = """
242+
{
243+
"success": false,
244+
"code": "COMMON_500",
245+
"message": "서버 오류가 발생했습니다.",
246+
"data": null
247+
}
248+
""")
249+
)
250+
)
251+
})
252+
ResponseEntity<RsData<PageResponse<CommentListResponse>>> getComments(
253+
@PathVariable Long postId,
254+
Pageable pageable
255+
);
256+
145257
@Operation(
146258
summary = "댓글 수정",
147259
description = "로그인한 사용자가 자신이 작성한 댓글을 수정합니다."

0 commit comments

Comments
 (0)