Skip to content

Commit df9c90a

Browse files
committed
convert empty structure payloads to null
1 parent 91f91d9 commit df9c90a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2486,6 +2486,14 @@ private HttpBinding readPayload(
24862486
Location.PAYLOAD, "data", binding.getMember(), target));
24872487
}
24882488
);
2489+
} else if (target instanceof StructureShape) {
2490+
writer.write("contents.$L = $L;", binding.getMemberName(), getOutputValue(context,
2491+
Location.PAYLOAD, "data", binding.getMember(), target));
2492+
// Handle empty objects for structure shapes - convert to null
2493+
writer.write("if (contents.$L && Object.keys(contents.$L).length === 0) {",
2494+
binding.getMemberName(), binding.getMemberName());
2495+
writer.write(" contents.$L = null;", binding.getMemberName());
2496+
writer.write("}");
24892497
} else {
24902498
writer.write("contents.$L = $L;", binding.getMemberName(), getOutputValue(context,
24912499
Location.PAYLOAD, "data", binding.getMember(), target));

0 commit comments

Comments
 (0)