Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

private/model: Handles empty map vs unset map behavior in send request #337

Merged
merged 5 commits into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
### SDK Enhancements

### SDK Bugs
* `private/model`: Handles empty map vs unset map behavior in send request ([#337](https://github.com/aws/aws-sdk-go-v2/pull/337))
* 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.
60 changes: 60 additions & 0 deletions models/protocol_tests/input/rest-json.json
Original file line number Diff line number Diff line change
Expand Up @@ -1657,5 +1657,65 @@
}
}
]
},
{
"description": "Empty or unset maps in payload",
"metadata": {
"protocol": "rest-json",
"apiVersion": "2014-01-01"
},
"shapes": {
"InputShape": {
"type": "structure",
"members": {
"MapEmpty": {
"shape": "MapStringStringType"
},
"MapDefaults": {
"shape": "MapStringStringType"
},
"MapNotSet": {
"shape": "MapStringStringType"
}
}
},
"MapStringStringType": {
"type": "map",
"key": {
"shape": "StringType"
},
"value": {
"shape": "StringType"
}
},
"StringType": {
"type": "string"
}
},
"cases": [
{
"given": {
"http": {
"method": "POST",
"requestUri": "/"
},
"input": {
"shape": "InputShape"
},
"name": "OperationName"
},
"params": {
"MapEmpty": {},
"MapDefaults": {"test_key_1": "test_value_1", "test_key_2": "test_value_2" ,"test_key_3": "test_value_3" }
},
"serialized": {
"body": "{\"MapDefaults\": {\"test_key_1\":\"test_value_1\", \"test_key_2\":\"test_value_2\", \"test_key_3\":\"test_value_3\"}, \"MapEmpty\":{}}",
"uri": "/",
"headers": {}
}
}
]
}
]


2 changes: 1 addition & 1 deletion private/model/api/shape_marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ var marshalShapeRefTmpl = template.Must(template.New("marshalShapeRefTmpl").Func
{{ $isList := $.IsShapeType "list" -}}
{{ $isMap := $.IsShapeType "map" -}}
{{- if or $isList $isMap -}}
len(s.{{ $.Name }}) > 0
s.{{ $.Name }} != nil
{{- else if $.Ref.Shape.IsEnum -}}
len(s.{{ $.Name }}) > 0
{{- else -}}
Expand Down
Loading