Skip to content

Commit ed4e589

Browse files
skotambkarjasdel
authored andcommitted
private/model: Handles empty map vs unset map behavior in send request (#337)
Updated shape marshal model to handle the empty map vs nil map behavior. Adding a test case to assert behavior when a user sends an empty map vs nil map. Fix #332
1 parent 99b7e3d commit ed4e589

File tree

923 files changed

+2400
-2125
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

923 files changed

+2400
-2125
lines changed

CHANGELOG_PENDING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
### SDK Enhancements
44

55
### SDK Bugs
6+
* `private/model`: Handles empty map vs unset map behavior in send request ([#337](https://github.com/aws/aws-sdk-go-v2/pull/337))
7+
* Updates shape marshal model to handle the empty map vs nil map behavior. Also adds a test case to assert behavior when a user sends an empty map vs unset map.
8+
* Fixes [#332](https://github.com/aws/aws-sdk-go-v2/issues/332)

models/protocol_tests/input/rest-json.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,5 +1657,65 @@
16571657
}
16581658
}
16591659
]
1660+
},
1661+
{
1662+
"description": "Empty or unset maps in payload",
1663+
"metadata": {
1664+
"protocol": "rest-json",
1665+
"apiVersion": "2014-01-01"
1666+
},
1667+
"shapes": {
1668+
"InputShape": {
1669+
"type": "structure",
1670+
"members": {
1671+
"MapEmpty": {
1672+
"shape": "MapStringStringType"
1673+
},
1674+
"MapDefaults": {
1675+
"shape": "MapStringStringType"
1676+
},
1677+
"MapNotSet": {
1678+
"shape": "MapStringStringType"
1679+
}
1680+
}
1681+
},
1682+
"MapStringStringType": {
1683+
"type": "map",
1684+
"key": {
1685+
"shape": "StringType"
1686+
},
1687+
"value": {
1688+
"shape": "StringType"
1689+
}
1690+
},
1691+
"StringType": {
1692+
"type": "string"
1693+
}
1694+
},
1695+
"cases": [
1696+
{
1697+
"given": {
1698+
"http": {
1699+
"method": "POST",
1700+
"requestUri": "/"
1701+
},
1702+
"input": {
1703+
"shape": "InputShape"
1704+
},
1705+
"name": "OperationName"
1706+
},
1707+
"params": {
1708+
"MapEmpty": {},
1709+
"MapDefaults": {"test_key_1": "test_value_1", "test_key_2": "test_value_2" ,"test_key_3": "test_value_3" }
1710+
},
1711+
"serialized": {
1712+
"body": "{\"MapDefaults\": {\"test_key_1\":\"test_value_1\", \"test_key_2\":\"test_value_2\", \"test_key_3\":\"test_value_3\"}, \"MapEmpty\":{}}",
1713+
"uri": "/",
1714+
"headers": {}
1715+
}
1716+
}
1717+
]
16601718
}
16611719
]
1720+
1721+

private/model/api/shape_marshal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ var marshalShapeRefTmpl = template.Must(template.New("marshalShapeRefTmpl").Func
292292
{{ $isList := $.IsShapeType "list" -}}
293293
{{ $isMap := $.IsShapeType "map" -}}
294294
{{- if or $isList $isMap -}}
295-
len(s.{{ $.Name }}) > 0
295+
s.{{ $.Name }} != nil
296296
{{- else if $.Ref.Shape.IsEnum -}}
297297
len(s.{{ $.Name }}) > 0
298298
{{- else -}}

0 commit comments

Comments
 (0)