-
Notifications
You must be signed in to change notification settings - Fork 109
fix(codegen): fix header type codegen for event streams #1694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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, () -> { | ||
| writer.write("headers[$1S] = { type: $2S, value: input.$1L }", memberName, | ||
| getEventHeaderType(headerMember)); | ||
| getEventHeaderType(target)); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| }); | ||
| } | ||
| } | ||
|
|
@@ -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()); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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