Skip to content

Commit

Permalink
🐞 BugFix/#87 - OCRUtil의 ObjectMapper에 FAIL_ON_UNKNOWN_PROPERTIES인 경우 …
Browse files Browse the repository at this point in the history
…에러가 발생하는 문제 해결
  • Loading branch information
dongkyeomjang committed Nov 22, 2024
1 parent 56badf0 commit 38227bb
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
13 changes: 13 additions & 0 deletions http/auth/AuthControllerHttpRequest.http
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ password={{auth.API_LOGIN_SUPER_USER.password}}
client.global.set("refresh_token", response.body.data.refresh_token);
%}

### 테스트용 더미5 로그인
// @no-log
POST {{host_url}}/api/v1/auth/login
Content-Type: application/x-www-form-urlencoded

serial_id={{auth.API_LOGIN_DUMMY5.serial_id}}&
password={{auth.API_LOGIN_DUMMY5.password}}

> {%
client.global.set("access_token", response.body.data.access_token);
client.global.set("refresh_token", response.body.data.refresh_token);
%}

### 1.1 사용자 로그인 (Kakao Oauth)
// @no-log
POST {{host_url}}/api/v1/oauth/login
Expand Down
2 changes: 1 addition & 1 deletion http/onjung/OnjungControllerHttpRequest.http
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Content-Type: multipart/form-data; boundary=boundary
Content-Disposition: form-data; name="file"; filename="receipt.jpg"
Content-Type: image/jpeg

< /Users/kyeom/Desktop/receipt3.jpeg
< /Users/kyeom/Desktop/receipt.jpeg

### 4.5 영수증 리뷰 등록하기
// @no-log
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/daon/onjung/core/dto/ReceiptOCRDto.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.daon.onjung.core.dto;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public record ReceiptOCRDto(

@JsonProperty("version")
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/com/daon/onjung/core/utility/OCRUtil.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.daon.onjung.core.utility;

import com.daon.onjung.core.dto.ReceiptOCRDto;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import net.minidev.json.JSONObject;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -28,7 +29,15 @@ public class OCRUtil {
@Value("${naver-cloud.ocr.key}")
private String ocrKey;

private final ObjectMapper objectMapper = new ObjectMapper();
private ObjectMapper objectMapper = new ObjectMapper();

public OCRUtil() {
this.objectMapper = new ObjectMapper();

// 추가 필드를 무시하고 DTO에 정의된 필드만 매핑
this.objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}


public String createOCRRequestUrl() {
return UriComponentsBuilder.fromHttpUrl(ocrUrl)
Expand Down

0 comments on commit 38227bb

Please sign in to comment.