From ba7164da52f1d886dcc7ee58d0f8e1e4c5250671 Mon Sep 17 00:00:00 2001 From: Russell Cohen Date: Tue, 12 Mar 2024 14:48:44 -0400 Subject: [PATCH 1/3] Protocol test for `: null` values in unions Servers are allowed (but not recommmended) to send `"key": null` for unset fields in unions. However, this behavior was not covered by protocol tests. These tests were dry-run on the Rust SDK. --- .../model/awsJson1_0/unions.smithy | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/smithy-aws-protocol-tests/model/awsJson1_0/unions.smithy b/smithy-aws-protocol-tests/model/awsJson1_0/unions.smithy index 8c4391538a1..e3821c68e93 100644 --- a/smithy-aws-protocol-tests/model/awsJson1_0/unions.smithy +++ b/smithy-aws-protocol-tests/model/awsJson1_0/unions.smithy @@ -43,6 +43,7 @@ union MyUnion { listValue: StringList, mapValue: StringMap, structureValue: GreetingStruct, + unitValue: Unit, } apply JsonUnions @httpRequestTests([ @@ -535,5 +536,41 @@ apply JsonUnions @httpResponseTests([ } } } + }, + { + id: "AwsJson10DeserializeAllowNulls" + appliesTo: "client" + documentation: "Allows for `: null` to be set for all unset fields" + protocol: awsJson1_0 + code: 200 + body: """ + { + "contents": { + "stringValue": null, + "booleanValue": null, + "numberValue": null, + "blobValue": null, + "timestampValue": null, + "enumValue": null, + "intEnumValue": null, + "listValue": null, + "mapValue": null, + "structureValue": { + "hi": "hello" + }, + "unitValue": null + } + }""" + bodyMediaType: "application/json" + headers: { + "Content-Type": "application/x-amz-json-1.0" + }, + params: { + contents: { + structureValue: { + hi: "hello" + } + } + } } ]) From 7744e93569c2b7c2396ca237704382dfa64d1b2b Mon Sep 17 00:00:00 2001 From: Russell Cohen Date: Fri, 15 Mar 2024 17:49:48 -0400 Subject: [PATCH 2/3] Update unions.smithy --- smithy-aws-protocol-tests/model/awsJson1_0/unions.smithy | 1 - 1 file changed, 1 deletion(-) diff --git a/smithy-aws-protocol-tests/model/awsJson1_0/unions.smithy b/smithy-aws-protocol-tests/model/awsJson1_0/unions.smithy index e3821c68e93..394bb97be8d 100644 --- a/smithy-aws-protocol-tests/model/awsJson1_0/unions.smithy +++ b/smithy-aws-protocol-tests/model/awsJson1_0/unions.smithy @@ -43,7 +43,6 @@ union MyUnion { listValue: StringList, mapValue: StringMap, structureValue: GreetingStruct, - unitValue: Unit, } apply JsonUnions @httpRequestTests([ From 85cdeb97bd53d2222a1c6ec558a1b93da9f136c6 Mon Sep 17 00:00:00 2001 From: Russell Cohen Date: Fri, 15 Mar 2024 17:50:13 -0400 Subject: [PATCH 3/3] Update unions.smithy --- smithy-aws-protocol-tests/model/awsJson1_0/unions.smithy | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/smithy-aws-protocol-tests/model/awsJson1_0/unions.smithy b/smithy-aws-protocol-tests/model/awsJson1_0/unions.smithy index 394bb97be8d..c5718bd734f 100644 --- a/smithy-aws-protocol-tests/model/awsJson1_0/unions.smithy +++ b/smithy-aws-protocol-tests/model/awsJson1_0/unions.smithy @@ -556,8 +556,7 @@ apply JsonUnions @httpResponseTests([ "mapValue": null, "structureValue": { "hi": "hello" - }, - "unitValue": null + } } }""" bodyMediaType: "application/json"