From 9a77a8c1c88acb926612915485778e983c88a00e Mon Sep 17 00:00:00 2001 From: 82marbag <69267416+82marbag@users.noreply.github.com> Date: Wed, 29 Mar 2023 18:30:00 +0100 Subject: [PATCH] Empty payload structure in tests (#2328) * Empty payload structure in tests Signed-off-by: Daniele Ahmed * Update ServerProtocolTestGenerator Signed-off-by: Daniele Ahmed * Update ServerProtocolTestGenerator Signed-off-by: Daniele Ahmed --------- Signed-off-by: Daniele Ahmed Co-authored-by: Zelda Hessler --- .../codegen/core/smithy/generators/Instantiator.kt | 11 +++++++++++ .../protocol/ServerProtocolTestGenerator.kt | 5 ----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/Instantiator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/Instantiator.kt index 5962e30cdb..e77f942a29 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/Instantiator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/Instantiator.kt @@ -30,6 +30,7 @@ import software.amazon.smithy.model.shapes.TimestampShape import software.amazon.smithy.model.shapes.UnionShape import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.model.traits.HttpHeaderTrait +import software.amazon.smithy.model.traits.HttpPayloadTrait import software.amazon.smithy.model.traits.HttpPrefixHeadersTrait import software.amazon.smithy.model.traits.StreamingTrait import software.amazon.smithy.rust.codegen.core.rustlang.CargoDependency @@ -361,6 +362,16 @@ open class Instantiator( renderMemberHelper(memberShape, value) } + shape.allMembers.entries + .firstOrNull { + it.value.hasTrait() && + !data.members.containsKey(Node.from(it.key)) && + model.expectShape(it.value.target) is StructureShape + } + ?.let { + renderMemberHelper(it.value, fillDefaultValue(model.expectShape(it.value.target))) + } + writer.rust(".build()") if (builderKindBehavior.hasFallibleBuilder(shape)) { writer.rust(".unwrap()") diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt index 46bf1fa443..34270f2fdf 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt @@ -762,11 +762,6 @@ class ServerProtocolTestGenerator( private const val RestJson = "aws.protocoltests.restjson#RestJson" private const val RestJsonValidation = "aws.protocoltests.restjson.validation#RestJsonValidation" private val ExpectFail: Set = setOf( - // Pending resolution from the Smithy team, see https://github.com/awslabs/smithy/issues/1068. - FailingTest(RestJson, "RestJsonHttpWithHeadersButNoPayload", TestType.Request), - - FailingTest(RestJson, "RestJsonHttpWithEmptyStructurePayload", TestType.Request), - // Endpoint trait is not implemented yet, see https://github.com/awslabs/smithy-rs/issues/950. FailingTest(RestJson, "RestJsonEndpointTrait", TestType.Request), FailingTest(RestJson, "RestJsonEndpointTraitWithHostLabel", TestType.Request),