com.sap.cloud.sdk.datamodel.odata omit empty fields on serialisation
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu tại com.sap.cloud.sdk.datamodel.odata.helper.FluentHelperUpdate.executeRequest() và kiểm tra cách các thực thể OData được tuần tự hóa cho các yêu cầu cập nhật. So sánh workaround excludingFields() hiện có với hành vi được yêu cầu; được xem là hoàn tất khi các trường null có thể được bỏ qua mà không cần liệt kê thủ công, trong khi các giá trị khác null và false vẫn được tuần tự hóa.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi all!
In the context of an OData update request we run into an error response from the SAP service called. We are using com.sap.cloud.sdk.datamodel:odata-core in version 3.65.0. The Method in Question is com.sap.cloud.sdk.datamodel.odata.helper.FluentHelperUpdate.executeRequest().
When serializing in REST calls with data from com.sap.cloud.sdk.datamodel.odata, empty fields are also rendered into the output:
{
"insuranceId" : "ABC123",
"terminationDate" : null,
"terminationReason" : "UNKNOWN",
"terminationWish" : null,
"terminationReceived" : "/Date(1648027328522)/",
"force" : false
}
This fails on the SAP side with HttpResult 400 - bad request, because these fields are either not allowed to be empty or not allowed to be included at all.
We are now looking for a way / a setting to prevent this, so that something like
{
"insuranceId" : "ABC123",
"terminationReason" : "UNKNOWN",
"terminationReceived" : "/Date(1648027328522)/",
"force" : false
}
is rendered out.
As a workaround, we are using com.sap.cloud.sdk.datamodel.odata.helper.FluentHelperUpdate.excludingFields() right now as follows.
final var emptyEntityFields = new ArrayList<EntityField>();
if(cancellation.getTerminationDate() == null) emptyEntityFields.add(new EntityField("terminationDate"));
if(cancellation.getTerminationWish() == null) emptyEntityFields.add(new EntityField("terminationWish"));
this.dmeEpaService.updateTerminationRequest(terminationRequest)
.replacingEntity()
.excludingFields(emptyEntityFields.toArray(EntityField[]::new))
.executeRequest(this.httpDestination);
This workaround is cumbersome and needed on every request affected. As an example, in the jackson environment there is the setting @JsonInclude(JsonInclude.Include.NON_NULL) to accomplish this for every entity class annotated that way. See com.fasterxml.jackson.annotation
Enum JsonInclude.Include.NON_NULL for details an an eample.
Thanks in advance and best regards
Peter Hahn
- Ngôn ngữ chính
- HTML
- Star
- 52
- Fork
- 57
- Merge trung bình
- 2 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 20
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của SAP/cloud-sdk
-
Docs: 2 broken linksĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 45/100
SAP/cloud-sdk#1861 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
feedback
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
SAP/cloud-sdk#1829 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của SAP/cloud-sdk
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
ROCm/rocm-libraries#15866 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
お問い合わせのメール送信に失敗しても成功と表示されるĐang mởarea: web
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
inabagumi/shinju-date#6823 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
ManageSieve proxy: a backend's NO/BYE greeting is skipped as a capability line and reported as EOFĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Case sensitive file extensionĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
dmtrKovalenko/odiff#191 ·