I'm trying to achieve this with Grape. I need to send relatively complex XML bodies including element attributes, something like shown in this sample:
<Travelers>
<Traveler>
<AnonymousTraveler>
<PTC Quantity="1">ADT</PTC>
</AnonymousTraveler>
</Traveler>
</Travelers>
And I'm trying to define nested params following a popular convention when converting XML to JSON (here just to ruby) which looks like this:
optional :Travelers, type: Array do
requires :Traveler, type: Hash do
optional :AnonymousTraveler, type: Hash do
requires :PTC, type: Hash do
requires :_Quantity, type: Integer
requires :__text, type: String
end
end
end
end
But obviously the XML parser is not following this underscores-based convention and throws the error messages:
[Travelers][Traveler][AnonymousTraveler][PTC][_Quantity] is missing
[Travelers][Traveler][AnonymousTraveler][PTC][__text] is missing
Any clue on how to intercept XML body parameters parser and include this convention logic?
0 comments:
Post a Comment