[DABOM-498] 상태코드 개선 작업 - #128
Conversation
- POST /customers/signup: @ResponseStatus(HttpStatus.CREATED) 추가 - POST /admin/signup: @ResponseStatus(HttpStatus.CREATED) 추가 - 리소스 생성 API는 201 Created를 반환하도록 통일
- POST /policies: @ResponseStatus(HttpStatus.CREATED) 추가
- POST /appeals: @ResponseStatus(HttpStatus.CREATED) 추가
- POST /appeals/{appealId}/comments: @ResponseStatus(HttpStatus.CREATED) 추가
- POST /appeals/emergency: @ResponseStatus(HttpStatus.CREATED) 추가
- POST /missions: @ResponseStatus(HttpStatus.CREATED) 추가
- POST /missions/{missionId}/request: @ResponseStatus(HttpStatus.CREATED) 추가
- DELETE /admin/rewards/templates/{id}: @ResponseStatus(HttpStatus.NO_CONTENT) 제거
- ApiResponse.success(null) 반환 시 200 OK가 올바른 상태 코드
- 204 No Content와 JSON 래퍼 동시 사용은 계약 모순
- POST /customers/signup: ApiResponse.success() → ApiResponse.created() - POST /admin/signup: ApiResponse.success() → ApiResponse.created() - 스타일 가이드 Section 5 생성 API 응답 규칙 준수
- POST /policies: ApiResponse.success() → ApiResponse.created() - 스타일 가이드 Section 5 생성 API 응답 규칙 준수
- POST /missions/{missionId}/request: ApiResponse.success() → ApiResponse.created()
- 스타일 가이드 Section 5 생성 API 응답 규칙 준수
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 프로젝트의 API 응답 상태 코드 일관성을 강화하기 위해 진행되었습니다. 기존에 ApiResponse 계약과 HTTP 상태 코드가 불일치했던 부분을 개선하여, 리소스 생성 시에는 201 Created를, 특정 삭제 작업 후에는 200 OK를 명확하게 반환하도록 수정했습니다. 이를 통해 API의 예측 가능성을 높이고 클라이언트와의 계약을 더욱 견고하게 만들었습니다. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
이 PR은 API 응답의 일관성을 높이기 위해 HTTP 상태 코드를 개선하는 좋은 변경입니다. 리소스 생성을 위한 POST 엔드포인트들에 201 Created 상태 코드를 일관되게 적용하고, 응답 본문이 있는 DELETE 요청에서 204 No Content를 제거한 점이 인상적입니다. 이러한 변경은 RESTful API 설계 원칙에 더 잘 부합하며 프로젝트의 코드 품질을 향상시킵니다.
다만, 한 가지 아쉬운 점은 컨트롤러의 상태 코드 변경에 따른 통합 테스트 코드의 수정이 누락된 것으로 보입니다. 예를 들어, MissionControllerIntegrationTest에서 POST /missions와 POST /missions/{missionId}/request API의 상태 코드 기댓값이 여전히 200 OK로 되어 있어 테스트가 실패할 가능성이 있습니다. PR을 머지하기 전에 관련 테스트 코드를 201 Created를 기대하도록 수정하는 것을 강력히 권장합니다.
- MissionControllerIntegrationTest: POST /missions, POST /missions/{id}/request 기댓값 isCreated()로 변경
- RewardControllerIntegrationTest: POST /missions/{id}/request 기댓값 isCreated()로 변경
- 컨트롤러 @ResponseStatus(HttpStatus.CREATED) 추가에 따른 테스트 동기화
SonarQube Quality Summary (Community)✅ Quality Gate PASSED Branch: Issues
Measures
🔗 Dashboard: https://sonarqube.swthewhite.store/dashboard?id=dabom-api-core&branch=refactor/DABOM-498 Generated automatically by GitHub Actions. |
🍀 이슈 & 티켓 넘버
🎯 목적
프로젝트의 공통
ApiResponse계약과 HTTP 상태 코드가 어긋난 API를 정리합니다.201 Created를 반환하도록 통일204 No Content와 JSON 래퍼를 동시에 사용하는 모순된 계약 수정ApiResponse.created()사용으로 통일📝 변경 사항
POST /customers/signup:@ResponseStatus(HttpStatus.CREATED)추가,ApiResponse.created()적용POST /admin/signup:@ResponseStatus(HttpStatus.CREATED)추가,ApiResponse.created()적용POST /policies:@ResponseStatus(HttpStatus.CREATED)추가,ApiResponse.created()적용POST /appeals:@ResponseStatus(HttpStatus.CREATED)추가POST /appeals/{appealId}/comments:@ResponseStatus(HttpStatus.CREATED)추가POST /appeals/emergency:@ResponseStatus(HttpStatus.CREATED)추가POST /missions:@ResponseStatus(HttpStatus.CREATED)추가POST /missions/{missionId}/request:@ResponseStatus(HttpStatus.CREATED)추가,ApiResponse.created()적용DELETE /admin/rewards/templates/{id}:@ResponseStatus(HttpStatus.NO_CONTENT)제거 →200 OK반환📂 변경 범위
🖥️ 주요 코드 설명
💬 리뷰어에게
ApiResponse.created()는 래퍼의message필드만 변경하고 HTTP 상태 코드는 바꾸지 않으므로,@ResponseStatus어노테이션으로 실제 상태 코드를 제어합니다.📋 체크리스트
기본
./gradlew build가 정상적으로 통과하는가?./gradlew spotlessApply checkstyleMain)코드 품질
Controller → Service → Repository → Entity)@Transactional은 Service에만 선언했는가?테스트
📌 참고 사항
200 + success=true에 의존하는 경우 배포 전 클라이언트 영향 확인 필요