Skip to content
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

[BLOOM-041] validation 추가, api 마이너 수정 #46 #48

Merged
merged 29 commits into from
Aug 15, 2024
Merged

Conversation

Dompoo
Copy link
Collaborator

@Dompoo Dompoo commented Aug 14, 2024

How

  • spring validation을 추가하였습니다.
  • validation 실패시 발생하는 예외에 대하여 전역 예외처리를 추가하였습니다.
  • validation이 실제 잘 동작하는지 확인하기 위한 테스트를 작성하였습니다.
  • api가 명세서와 다른 부분이 몇개 발견되어, 수정하였습니다.
  • 도메인 엔티티 생성/연관관계 매핑 코드를 requestDto가 아니라, 도메인 엔티티 자체에서 수행하도록 리팩토링했습니다.

Result

  • validation
    • 이제 요청으로 들어오는 request를 검증할 수 있게 되었습니다.
  • api
    • 식물 저장 api의 요청에서 scientificName 대신에 plantId를 받습니다.
    • 식물 전체 조회 api의 응답에서 이제 각 식물의 대표 이미지를 볼 수 있습니다.
    • 식물 전체 조회 api의 경우 계층끼리 잘 작동하는지 확인하기 위해 따로 통합테스트를 진행하였습니다.
    • 수정된 api들도 swagger 문서화 적용하였습니다.

Dompoo added 25 commits August 14, 2024 02:43
@Dompoo Dompoo added 🌱 feat Suggest a new feature or enhancement 🔨 fix Request a fix for an existing feature 📚 docs Suggest improvements or additions to documentation labels Aug 14, 2024
@Dompoo Dompoo self-assigned this Aug 14, 2024
@Dompoo Dompoo requested a review from stophwan as a code owner August 14, 2024 06:42
@Dompoo Dompoo linked an issue Aug 14, 2024 that may be closed by this pull request
Copy link
Member

@stophwan stophwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

일단 고생하셨습니다! NotNull을 사용하면서 nullable하게 설정하지 않으면 역직렬화에서 막혀버리는군요.
모든 request에 NotNull 어노테이션이 들어가는게 올바른 방식만은 아닐 것 같아, 차후에 HttpMessageNotReadableException일 경우 따로 처리하는 예외를 만드는게 나아보인다는 생각도 드네요. null을 허용하지 않은 필드인데 request 스펙 자체를 지키지 않은거니까요. 이에 대해서는 어떻게 생각하시나요?
++ 추가적으로 BaseEntity 필드가 LocalDateTime이 아닌 LocalDate로 되어있습니다..!

@Dompoo Dompoo merged commit c306607 into main Aug 15, 2024
2 checks passed
@Dompoo Dompoo deleted the feat/validation branch August 15, 2024 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 docs Suggest improvements or additions to documentation 🌱 feat Suggest a new feature or enhancement 🔨 fix Request a fix for an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feat] 요청 필드 Validation 추가
2 participants