Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Api/Serializer/RestXmlSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ protected function payload(StructureShape $member, array $value, array &$opts)
*/
private function getXmlBody(StructureShape $member, array $value)
{
$xmlBody = (string)$this->xmlBody->build($member, $value);
$xmlBody = $this->xmlBody->build($member, $value);
$xmlBody = str_replace("'", "'", $xmlBody);
$xmlBody = str_replace('\r', "
", $xmlBody);
$xmlBody = str_replace('\n', "
", $xmlBody);
Expand Down
6 changes: 2 additions & 4 deletions src/Api/Serializer/XmlBody.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,8 @@ private function add_structure(
// Default to member name
$elementName = $k;

// Only use locationName for non-structure members
if (!($definition['member'] instanceof StructureShape)
&& $definition['member']['locationName']
) {
if ($definition['member']['locationName']
&& !isset($definition['member']['locationNameAtStructureLevel'])) {
$elementName = $definition['member']['locationName'];
}

Expand Down
9 changes: 8 additions & 1 deletion src/Api/ShapeMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,14 @@ public function resolve(array $shapeRef)
return $this->simple[$shape];
}

$definition = $shapeRef + $this->definitions[$shape];
$shapeDefinition = $this->definitions[$shape];
$definition = $shapeRef + $shapeDefinition;
// Property to know whether the locationName was set at member level
// or the structure level.
if (isset($shapeDefinition['locationName'])) {
$definition['locationNameAtStructureLevel'] = true;
}

$definition['name'] = $definition['shape'];
if (isset($definition['shape'])) {
unset($definition['shape']);
Expand Down
78 changes: 78 additions & 0 deletions tests/Api/test_cases/protocols/input/rest-xml.json
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,84 @@
}
]
},
{
"description": "Test cases for xmlName at member level operation",
"metadata": {
"apiVersion": "2019-12-16",
"auth": [
"aws.auth#sigv4"
],
"endpointPrefix": "restxml",
"protocol": "rest-xml",
"protocols": [
"rest-xml"
],
"serviceFullName": "RestXml",
"serviceId": "Rest Xml Protocol",
"signatureVersion": "v4",
"signingName": "RestXml",
"uid": "rest-xml-protocol-2019-12-16"
},
"shapes": {
"MyShapeInputAndOutput": {
"type": "structure",
"members": {
"nested": {
"shape": "Payload",
"locationName": "CustomPayload"
}
},
"locationName": "MyShape"
},
"Payload": {
"type": "structure",
"members": {
"name": {
"shape": "String"
}
}
},
"String": {
"type": "string"
}
},
"cases": [
{
"id": "XMLNameAtMemberLevel",
"given": {
"name": "XMLNameAtMemberLevel",
"http": {
"method": "PUT",
"requestUri": "/XMLNameAtMemberLevel",
"responseCode": 200
},
"input": {
"shape": "MyShapeInputAndOutput",
"locationName": "XMLNameAtMemberLevelRequest"
},
"documentation": "<p>The following example serializes a body that uses an XML name, changing the wrapper name.</p>",
"idempotent": true
},
"description": "Serializes a payload using a wrapper name based on the xmlName",
"params": {
"nested": {
"name": "TestParameterValue"
}
},
"serialized": {
"method": "PUT",
"uri": "/XMLNameAtMemberLevel",
"body": "<MyShape><CustomPayload><name>TestParameterValue</name></CustomPayload></MyShape>",
"headers": {
"Content-Type": "application/xml"
},
"requireHeaders": [
"Content-Length"
]
}
}
]
},
{
"description": "Test cases for ConstantAndVariableQueryString operation",
"metadata": {
Expand Down