Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,9 @@ private void writeEventHeaders(GenerationContext context, StructureShape event)
for (MemberShape headerMember : headerMembers) {
String memberName = headerMember.getMemberName();
Shape target = model.expectShape(headerMember.getTarget());
writer.openBlock("if (input.$L) {", "}", memberName, () -> {
writer.openBlock("if (input.$L != null) {", "}", memberName, () -> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allow zero numbers and empty strings

writer.write("headers[$1S] = { type: $2S, value: input.$1L }", memberName,
getEventHeaderType(headerMember));
getEventHeaderType(target));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the member target shape type is what runs against the switch statement.

Using the member itself always goes to the default branch because the shape type is MEMBER.

});
}
}
Expand All @@ -356,7 +356,7 @@ private String getEventHeaderType(Shape shape) {
case BLOB:
return "binary";
default:
return "binary";
throw new IllegalArgumentException("Unsupported event header shape type: " + shape.getType());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be no default, since all supported types are accounted for, see https://smithy.io/2.0/spec/streaming.html#eventheader-trait

}
}

Expand Down
Loading