Skip to content

Commit

Permalink
Minor stub fixes for downstream (AWS)
Browse files Browse the repository at this point in the history
  • Loading branch information
alextwoods committed Aug 19, 2024
1 parent a024bff commit 48da637
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
24 changes: 12 additions & 12 deletions codegen/projections/white_label/lib/white_label/stubs.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ protected void renderBodyStubber(Shape shape, boolean isEventStream) {
} else {
MemberShape payloadMember = httpPayloadMembers.get(0);
Shape target = model.expectShape(payloadMember.getTarget());
renderPayloadBodyStub(shape, payloadMember, target);
// event stream members may be marked with httpPayload in REST protocols
// but should not be stubbed as the body.
if (!StreamingTrait.isEventStream(model, payloadMember)) {
renderPayloadBodyStub(shape, payloadMember, target);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,12 @@ protected void renderEventStubMethod(StructureShape event) {
.findFirst();

writer
.openBlock("def self.stub(stub)")
.openBlock("def self.stub(event_type, stub)")
.write("message = Hearth::EventStream::Message.new")
.write("message.headers[':message-type'] = "
+ "Hearth::EventStream::HeaderValue.new(value: 'event', type: 'string')")
.write("message.headers[':event-type'] = "
+ "Hearth::EventStream::HeaderValue.new(value: '$L', type: 'string')",
event.getId().getName())
+ "Hearth::EventStream::HeaderValue.new(value: event_type, type: 'string')")
.call(() -> {
renderStubEventHeaders(event);
})
Expand Down Expand Up @@ -440,8 +439,9 @@ private void renderStubEventMethod(UnionShape eventStreamUnion) {
writer
.write("when $T", symbolProvider.toSymbol(target))
.indent()
.write("EventStream::$L.stub(stub)",
symbolProvider.toSymbol(target).getName())
.write("EventStream::$L.stub('$L', stub)",
symbolProvider.toSymbol(target).getName(),
symbolProvider.toMemberName(memberShape))
.dedent();
}
})
Expand Down

0 comments on commit 48da637

Please sign in to comment.