From df9c90afd49488d5bfef035609dd608fa065b3d5 Mon Sep 17 00:00:00 2001 From: smilkuri Date: Fri, 11 Jul 2025 15:22:51 +0000 Subject: [PATCH] convert empty structure payloads to null --- .../codegen/integration/HttpBindingProtocolGenerator.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java index d38dff08145..8aa98cdb0e5 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java @@ -2486,6 +2486,14 @@ private HttpBinding readPayload( Location.PAYLOAD, "data", binding.getMember(), target)); } ); + } else if (target instanceof StructureShape) { + writer.write("contents.$L = $L;", binding.getMemberName(), getOutputValue(context, + Location.PAYLOAD, "data", binding.getMember(), target)); + // Handle empty objects for structure shapes - convert to null + writer.write("if (contents.$L && Object.keys(contents.$L).length === 0) {", + binding.getMemberName(), binding.getMemberName()); + writer.write(" contents.$L = null;", binding.getMemberName()); + writer.write("}"); } else { writer.write("contents.$L = $L;", binding.getMemberName(), getOutputValue(context, Location.PAYLOAD, "data", binding.getMember(), target));