Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
Expand Down Expand Up @@ -86,7 +85,7 @@ public CustomResponse<MyEditInfoResponseDto> getMyEditInfo(
return CustomResponse.ok(userService.getMyEditInfo(userDetails.getUserId()));
}

@PostMapping("/me/edit")
@PatchMapping("/me/edit")
Copy link
Contributor

Choose a reason for hiding this comment

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

high

@PatchMapping으로 변경된 이 엔드포인트는 부분 업데이트를 위한 RESTful한 접근 방식입니다. 그러나 이 엔드포인트에서 사용되는 MyEditInfoRequestDto의 모든 필드(nickname, address, detailAddress)에 @NotBlank 유효성 검사가 적용되어 있습니다. 이는 클라이언트가 이 필드들 중 일부만 전송하여 부분 업데이트를 시도할 경우 유효성 검사 오류를 발생시킬 수 있습니다. 만약 부분 업데이트를 허용할 의도라면, MyEditInfoRequestDto@NotBlank 어노테이션을 제거하거나, 업데이트할 필드만 포함하는 별도의 DTO를 사용하는 것을 고려해야 합니다.

References
  1. The suggestion to use a separate DTO for partial updates aligns with the principle of Rule 5, which advises against including fields in a DTO that are not currently required by a consumer. For a PATCH operation, only the fields being updated are 'required' by the consumer, making a dedicated DTO more appropriate.

public CustomResponse<Void> updateMyInfo(
@AuthenticationPrincipal CustomUserDetails userDetails,
@Valid @RequestBody MyEditInfoRequestDto request
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package com.example.RealMatch.user.presentation.dto.request;

import jakarta.validation.constraints.NotBlank;

public record MyEditInfoRequestDto(
@NotBlank(message = "닉네임은 필수입니다.")

String nickname,

@NotBlank(message = "주소는 필수입니다.")
String address,

@NotBlank(message = "상세 주소는 필수입니다.")
String detailAddress
) {
}
Loading