Inconsistent XML element names when returning an array versus an object
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
- 25/100
Hướng nghiên cứu
Start with item.rb and compare the XML serialization entry points for an array of Items and a single Item. Review issues #38 and #23, including the formatter and root approaches mentioned there. Done means establishing consistent element names without making the JSON keys inconsistent.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I have an entity that I am using both for presenting an array of Item objects as well as singular Item objects. I was surprised to see that when returning XML the element names are different in these two very similar situations.
item.rb
module Legacy
module V1
module Entities
# Defines the combined item entity
class Item < Grape::Entity
expose :object, as: 'itemmast', using: Entities::Itemmast
expose :object, as: 'loclvl', using: Entities::Loclvl
end
end
end
end
Response Body: Array of Items
<legacy_v1_entities_items type="array">
<legacy_v1_entities_item>
<itemmast>
<ALPHAPC>00001</ALPHAPC>
<PC type="integer">1</PC>
</itemmast>
<loclvl>
<UPC type="integer">1</UPC>
</loclvl>
</legacy_v1_entities_item>
<legacy_v1_entities_item>
<itemmast>
<ALPHAPC>00002</ALPHAPC>
<PC type="integer">2</PC>
</itemmast>
<loclvl>
<UPC type="integer">2</UPC>
</loclvl>
</legacy_v1_entities_item>
</legacy_v1_entities_items>
Response Body: Single Item Object
<hash>
<itemmast>
<ALPHAPC>00001</ALPHAPC>
<PC type="integer">1</PC>
</itemmast>
<loclvl>
<UPC type="integer">1</UPC>
</loclvl>
</hash>
I've looked at issues #38 and #23, and while I can add a formatter as suggested this can lead to issues with entities which don't follow the same pattern. Additionally, if I change the root in this particular entity, the keys in the resulting JSON response are then inconsistent. Can anyone point me in the right direction of how to approach solving this inconsistency?
- Ngôn ngữ chính
- Ruby
- Star
- 730
- Fork
- 154
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không 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 ruby-grape/grape-entity
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
ruby-grape/grape-entity#386 · 7 bình luận · 1 reaction ·
-
Custom Entity options supportĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
ruby-grape/grape-entity#382 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
ruby-grape/grape-entity#380 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
ruby-grape/grape-entity#373 · 2 bình luận ·
-
Truncate FormatterĐang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 45/100
ruby-grape/grape-entity#372 ·
Tất cả issue của ruby-grape/grape-entity
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
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 74/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
thewca/worldcubeassociation.org#16088 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
cocoapods: bundled activesupport raises `unknown keyword: quirks_mode` once json 3 is installedĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Homebrew/homebrew-core#319232 ·
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 66/100
Maintainer thường phản hồi trong vòng 1 ngày