Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Update REST API classes to remove extraneous wrapper classes

Đang mở
#3 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
java, spring-boot
Lĩnh vực
api, backend

Hướng nghiên cứu

Bắt đầu với các lớp mô hình REST API, bao gồm Webhook và Product, rồi so sánh cách các chú thích wrapper của Jackson xử lý các đối tượng đơn lẻ so với các collection. Tái tạo các dạng response Product và products được ghi trong tài liệu, sau đó xác định liệu có thể loại bỏ các wrapper Root mà vẫn bảo toàn cả hai dạng deserialization hay không; issue không xác định các file hoặc test cụ thể.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement good first issue

Much of the REST API model has "Root" classes which are just wrappers to handle the name of a JSON node.

I think we can get rid of all of those, by defining the actual model classes with a couple JSON annotations. An example is the Webhook class:

@JsonTypeName(value = "webhook")
@JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME)


Update:

This is trickier than expected. The main approach works fine for single item use, but causes issues when there's an array of items being mapped to a collection.

For example, for a single Product call, Shopify returns something like:

{
"product": {
"id": 632910392,
"title": "IPod Nano - 8GB",
"body_html": "

It's the small iPod......

Which is why we need the Product class to have the As.WRAPPER_OBJECT annotation (or the wrapper class).

However, when getting an array of products, Shopify sends in something like this:

{
"products": [
{
"id": 632910392,
"title": "IPod Nano - 8GB",
"body_html": "

It's the small iPo

Note the lack of "product" level nodes. That's what breaks here. So basically we want Product to wrap itself with a "product" node if it's a single Product, but to NOT wrap itself when its an array or collection. I can't find any easy way to do this. A custom de-serializer is an option, but I'm not sure that's a lot better/cleaner than these wrapper classes....

Ngôn ngữ chính
Java
Star
55
Fork
18
Merge trung bình
11 giờ 19 phút
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của devondragon/SpringShopifyAppFramework

Tất cả issue của devondragon/SpringShopifyAppFramework

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.