Skip to content

Commit cecca43

Browse files
committed
Docs: Swagger 문서 작성
1 parent 73d1df7 commit cecca43

File tree

1 file changed

+144
-0
lines changed

1 file changed

+144
-0
lines changed

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

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,4 +294,148 @@ ResponseEntity<RsData<PageResponse<PostListResponse>>> getPosts(
294294
ResponseEntity<RsData<PostDetailResponse>> getPost(
295295
@PathVariable Long postId
296296
);
297+
298+
@Operation(
299+
summary = "게시글 수정",
300+
description = "로그인한 사용자가 자신의 게시글을 수정합니다."
301+
)
302+
@ApiResponses({
303+
@ApiResponse(
304+
responseCode = "200",
305+
description = "게시글 수정 성공",
306+
content = @Content(
307+
mediaType = "application/json",
308+
examples = @ExampleObject(value = """
309+
{
310+
"success": true,
311+
"code": "SUCCESS_200",
312+
"message": "게시글이 수정되었습니다.",
313+
"data": {
314+
"postId": 101,
315+
"author": {
316+
"id": 5,
317+
"nickname": "홍길동"
318+
},
319+
"title": "수정된 게시글",
320+
"content": "안녕하세요, 수정했습니다!",
321+
"categories": [
322+
{ "id": 1, "name": "공지사항" },
323+
{ "id": 2, "name": "자유게시판" }
324+
],
325+
"createdAt": "2025-09-22T10:30:00",
326+
"updatedAt": "2025-09-22T10:30:00"
327+
}
328+
}
329+
""")
330+
)
331+
),
332+
@ApiResponse(
333+
responseCode = "400",
334+
description = "잘못된 요청 (필드 누락 등)",
335+
content = @Content(
336+
mediaType = "application/json",
337+
examples = @ExampleObject(value = """
338+
{
339+
"success": false,
340+
"code": "COMMON_400",
341+
"message": "잘못된 요청입니다.",
342+
"data": null
343+
}
344+
""")
345+
)
346+
),
347+
@ApiResponse(
348+
responseCode = "401",
349+
description = "인증 실패 (토큰 없음/만료/잘못됨)",
350+
content = @Content(
351+
mediaType = "application/json",
352+
examples = {
353+
@ExampleObject(name = "토큰 없음", value = """
354+
{
355+
"success": false,
356+
"code": "AUTH_001",
357+
"message": "인증이 필요합니다.",
358+
"data": null
359+
}
360+
"""),
361+
@ExampleObject(name = "잘못된 토큰", value = """
362+
{
363+
"success": false,
364+
"code": "AUTH_002",
365+
"message": "유효하지 않은 액세스 토큰입니다.",
366+
"data": null
367+
}
368+
"""),
369+
@ExampleObject(name = "만료된 토큰", value = """
370+
{
371+
"success": false,
372+
"code": "AUTH_004",
373+
"message": "만료된 액세스 토큰입니다.",
374+
"data": null
375+
}
376+
""")
377+
}
378+
)
379+
),
380+
@ApiResponse(
381+
responseCode = "403",
382+
description = "권한 없음 (작성자 아님)",
383+
content = @Content(
384+
mediaType = "application/json",
385+
examples = @ExampleObject(value = """
386+
{
387+
"success": false,
388+
"code": "POST_002",
389+
"message": "게시글 작성자만 수정/삭제할 수 있습니다.",
390+
"data": null
391+
}
392+
""")
393+
)
394+
),
395+
@ApiResponse(
396+
responseCode = "404",
397+
description = "존재하지 않는 게시글 또는 카테고리",
398+
content = @Content(
399+
mediaType = "application/json",
400+
examples = {
401+
@ExampleObject(name = "존재하지 않는 게시글", value = """
402+
{
403+
"success": false,
404+
"code": "POST_001",
405+
"message": "존재하지 않는 게시글입니다.",
406+
"data": null
407+
}
408+
"""),
409+
@ExampleObject(name = "존재하지 않는 카테고리", value = """
410+
{
411+
"success": false,
412+
"code": "POST_003",
413+
"message": "존재하지 않는 카테고리입니다.",
414+
"data": null
415+
}
416+
""")
417+
}
418+
)
419+
),
420+
@ApiResponse(
421+
responseCode = "500",
422+
description = "서버 내부 오류",
423+
content = @Content(
424+
mediaType = "application/json",
425+
examples = @ExampleObject(value = """
426+
{
427+
"success": false,
428+
"code": "COMMON_500",
429+
"message": "서버 오류가 발생했습니다.",
430+
"data": null
431+
}
432+
""")
433+
)
434+
)
435+
})
436+
ResponseEntity<RsData<PostResponse>> updatePost(
437+
@PathVariable Long postId,
438+
@RequestBody PostRequest request,
439+
@AuthenticationPrincipal CustomUserDetails user
440+
);
297441
}

0 commit comments

Comments
 (0)