diff --git a/build_tools/aws-sdk-code-generator/spec/protocols/output/rest-json.json b/build_tools/aws-sdk-code-generator/spec/protocols/output/rest-json.json index f64ed4681f0..d85cf974ce5 100644 --- a/build_tools/aws-sdk-code-generator/spec/protocols/output/rest-json.json +++ b/build_tools/aws-sdk-code-generator/spec/protocols/output/rest-json.json @@ -1032,6 +1032,44 @@ "headers": {}, "body": "{\"UnionMember\": {\"SomeUnknownMember\": \"un-modeled member\"}}" } + }, + { + "given": { + "output": { + "shape": "OutputShape" + }, + "name": "OperationName" + }, + "result": { + "UnionMember": {"S": "string value"} + }, + "resultClass": { + "UnionMember": "UnionType::S" + }, + "response": { + "status_code": 200, + "headers": {}, + "body": "{\"UnionMember\": {\"__type\": \"UnionType\", \"S\": \"string value\"}}" + } + }, + { + "given": { + "output": { + "shape": "OutputShape" + }, + "name": "OperationName" + }, + "result": { + "UnionMember": {"Unknown": {"name": "SomeUnknownMember", "value": "un-modeled member"}} + }, + "resultClass": { + "UnionMember": "UnionType::Unknown" + }, + "response": { + "status_code": 200, + "headers": {}, + "body": "{\"UnionMember\": {\"SomeUnknownMember\": \"un-modeled member\", \"__type\": \"UnionType\"}}" + } } ] } diff --git a/gems/aws-sdk-core/CHANGELOG.md b/gems/aws-sdk-core/CHANGELOG.md index 6eb8ec46376..9814d7e416b 100644 --- a/gems/aws-sdk-core/CHANGELOG.md +++ b/gems/aws-sdk-core/CHANGELOG.md @@ -1,6 +1,8 @@ Unreleased Changes ------------------ +* Issue - Ignore `__type` when deserializing Unions. + 3.185.0 (2023-10-02) ------------------ diff --git a/gems/aws-sdk-core/lib/aws-sdk-core/json/parser.rb b/gems/aws-sdk-core/lib/aws-sdk-core/json/parser.rb index bd47974db52..00aed911932 100644 --- a/gems/aws-sdk-core/lib/aws-sdk-core/json/parser.rb +++ b/gems/aws-sdk-core/lib/aws-sdk-core/json/parser.rb @@ -28,7 +28,7 @@ def structure(ref, values, target = nil) member_name, member_ref = shape.member_by_location_name(key) if member_ref target[member_name] = parse_ref(member_ref, value) - elsif shape.union + elsif shape.union && key != '__type' target[:unknown] = { 'name' => key, 'value' => value } end end