728x90
에러 상황
Spring Rest Docs를 사용해서 테스트를 진행하던 중 오류가 발생했다.
에러 코드
Fields with the following paths were not found in the payload
해결 방법
fieldWithPath 사용 시 테이블 컬럼의 데이터가 비어있거나 null 값이 있는 경우 optional 처리를 해줘야 한다.
// 기존 코드
fieldWithPath("list[].car_number").type(JsonFieldType.STRING).description("차량 번호")
// 변경 코드
fieldWithPath("list[].car_number").type(JsonFieldType.STRING).description("차량 번호").optional()
728x90
댓글