Skip to content

Commit

Permalink
Fix XML parsing flattened shape from shape ref (#1766)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjyclaire authored Apr 24, 2018
1 parent 4edc8bc commit c39d9be
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,61 @@
}
]
},
{
"description": "Shape Reference Flattened List",
"metadata": {
"protocol": "rest-xml"
},
"shapes": {
"OutputShape": {
"type": "structure",
"members": {
"ListMember": {
"shape": "StructureList",
"flattened": true
}
}
},
"StructureList": {
"type": "list",
"member": {
"shape": "Tag"
}
},
"Tag": {
"type": "structure",
"members": {
"Key": {
"shape": "StringType"
},
"Value": {
"shape": "StringType"
}
}
},
"StringType": {
"type": "string"
}
},
"cases": [
{
"given": {
"output": {
"shape": "OutputShape"
},
"name": "OperationName"
},
"result": {
"ListMember": [{"key": "foo", "value": "bar"}, {"key": "bar", "value": "baz"}]
},
"response": {
"status_code": 200,
"headers": {},
"body": "<OperationNameResult><ListMember><Key>foo</Key><Value>bar</Value></ListMember><ListMember><Key>bar</Key><Value>baz</Value></ListMember></OperationNameResult>"
}
}
]
},
{
"description": "Normal map",
"metadata": {
Expand Down
2 changes: 2 additions & 0 deletions gems/aws-sdk-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Unreleased Changes
------------------

* Issue - Fix parsing flattened XML shape from shape reference for S3 https://github.com/aws/aws-sdk-ruby/issues/1764

3.20.0 (2018-04-23)
------------------

Expand Down
10 changes: 5 additions & 5 deletions gems/aws-sdk-core/lib/aws-sdk-core/xml/parser/frame.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def new(path, parent, ref, result = nil)

def frame_class(ref)
klass = FRAME_CLASSES[ref.shape.class]
if ListFrame == klass && ref.shape.flattened
if ListFrame == klass && (ref.shape.flattened || ref["flattened"])
FlatListFrame
elsif MapFrame == klass && ref.shape.flattened
elsif MapFrame == klass && (ref.shape.flattened || ref["flattened"])
MapEntryFrame
else
klass
Expand Down Expand Up @@ -120,15 +120,15 @@ def apply_default_value(name, ref)
end

def xml_name(ref)
if flattened_list?(ref.shape)
if flattened_list?(ref)
ref.shape.member.location_name || ref.location_name
else
ref.location_name
end
end

def flattened_list?(shape)
ListShape === shape && shape.flattened
def flattened_list?(ref)
ListShape === ref.shape && (ref.shape.flattened || ref["flattened"])
end

end
Expand Down

0 comments on commit c39d9be

Please sign in to comment.