-
Notifications
You must be signed in to change notification settings - Fork 2
docs: Swagger UI 문서 전면 개선 - 에러 응답 자동화, 스키마 수정, 204 응답 개선 #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- auth, post, participation, comment, like, s3, profile, verification 도메인 적용
- 명시적 스키마를 제거해 메서드 시그니처의 ResponseEntity<ApiResult<T>>로 자동 생성되도록 수정
- 명시적 스키마를 제거해 메서드 시그니처의 ResponseEntity<ApiResult<T>>로 자동 생성되도록 수정
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR standardizes Swagger/OpenAPI documentation by replacing manual error response definitions with the @ApiErrorResponses annotation across API documentation interfaces. The changes improve consistency and maintainability by automatically generating error responses from ErrorCode enums.
Key changes:
- Introduced
@ApiErrorResponsesannotation to automatically generate error response documentation fromErrorCodeenums across all API documentation interfaces - Fixed incorrect response schemas by removing redundant manual schema definitions that conflicted with automatic generation
- Added
content = @Content()to 204 No Content responses to prevent Swagger UI from displaying misleading body examples - Corrected
SurveyControllerto useApiResult.created()instead ofApiResult.ok()for 201 responses, ensuring the internal status field matches the HTTP status code
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| PhoneVerificationApiDocs.java | Replaced verbose manual error responses with @ApiErrorResponses annotation for verification code sending and verification endpoints |
| SurveyController.java | Fixed inconsistency by using ApiResult.created() for 201 status and simplified 200 OK response creation |
| SurveyApiDocs.java | Removed redundant schema definitions from success responses to allow automatic generation |
| ProfileApiDocs.java | Added content = @Content() to 204 responses and replaced manual error definitions with @ApiErrorResponses |
| PostApiDocs.java | Replaced wildcard imports with explicit imports, added @ApiErrorResponses for all endpoints, and ensured 204 responses have empty content |
| ParticipationApiDocs.java | Migrated all endpoints to use @ApiErrorResponses and added content = @Content() to 204 responses |
| PostLikeApiDocs.java | Added @ApiErrorResponses for toggle endpoint and fixed 204 response content |
| CommentLikeApiDocs.java | Added @ApiErrorResponses for toggle endpoint and fixed 204 response content |
| CommentApiDocs.java | Replaced manual error responses with @ApiErrorResponses for create, retrieve, delete, and update operations |
| OauthApiDocs.java | Migrated authentication endpoints to use @ApiErrorResponses and fixed 204 logout response |
| S3ApiDocs.java | Removed redundant schema definition and added @ApiErrorResponses for file upload endpoint |
Comments suppressed due to low confidence (1)
src/main/java/com/dduru/gildongmu/survey/controller/SurveyApiDocs.java:114
- The
SurveyApiDocsinterface was not updated to use the new@ApiErrorResponsesannotation pattern like other ApiDocs files. According to the PR description, all ApiDocs should be migrated to use@ApiErrorResponsesfor consistency. This file still uses the old manual@ApiResponseswith detailed error examples.
Consider updating this file to follow the same pattern as other ApiDocs:
- Replace the manual error response definitions with
@ApiErrorResponsesannotations - For the
submitSurveymethod, add error codes likeErrorCode.INVALID_INPUT_VALUE - For the
getMySurveyResultmethod, add error codes likeErrorCode.SURVEY_RESULT_NOT_FOUNDandErrorCode.UNAUTHORIZED
@ApiResponses({
@ApiResponse(
responseCode = "201",
description = "설문 제출 성공"
),
@ApiResponse(
responseCode = "400",
description = "잘못된 요청 (유효하지 않은 답변 코드, 필수 질문 미응답, Q7 범위 초과 등)",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = ErrorResponse.class),
examples = {
@ExampleObject(
name = "InvalidAnswerCode",
value = """
{
"status": 400,
"data": {
"errorCode": "INVALID_INPUT_VALUE",
"field": null,
"message": "Q1 이동수단에 대한 유효하지 않은 답변 코드입니다: 99"
}
}
"""
),
@ExampleObject(
name = "ValidationError",
value = """
{
"status": 400,
"data": {
"errorCode": "INVALID_INPUT_VALUE",
"field": "q1",
"message": "Q1 이동수단은 필수입니다."
}
}
"""
),
@ExampleObject(
name = "InvalidQ7Size",
value = """
{
"status": 400,
"data": {
"errorCode": "INVALID_INPUT_VALUE",
"field": "q7",
"message": "Q7 선호활동은 최대 3개까지 선택할 수 있습니다."
}
}
"""
)
}
)
)
})
ResponseEntity<ApiResult<SurveyResponse>> submitSurvey(
@Parameter(hidden = true) Long userId,
@Valid SurveyRequest request
);
@Operation(summary = "내 설문 결과 조회", description = "현재 사용자의 설문 결과 및 매칭된 아바타를 조회합니다.")
@ApiResponses({
@ApiResponse(
responseCode = "200",
description = "조회 성공"
),
@ApiResponse(
responseCode = "404",
description = "설문 결과를 찾을 수 없음",
content = @Content(
mediaType = "application/json",
schema = @Schema(implementation = ErrorResponse.class),
examples = @ExampleObject(
name = "SurveyResultNotFound",
value = """
{
"status": 404,
"data": {
"errorCode": "SURVEY_RESULT_NOT_FOUND",
"field": null,
"message": "설문 결과를 찾을 수 없습니다."
}
}
"""
)
)
)
})
ResponseEntity<ApiResult<SurveyResponse>> getMySurveyResult(
@Parameter(hidden = true) Long userId
);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jaejoong0529
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니당
🔎 작업 내용
@ApiErrorResponses어노테이션 추가하여 실제 에러 처리와 일치하도록 개선content = @Content()추가➕ 이슈 링크
📸 스크린샷
성공 응답
😎 리뷰 요구사항
@ApiErrorResponses를 통해 자동으로 생성되도록 통일했습니다.🧑💻 예정 작업
📝 체크리스트
feature/개발내용형식으로 작성했는가?feat: 커밋 내용형식으로 작성했는가?dev브랜치로 병합을 요청했는가?