Skip to content

Commit

Permalink
codegen: Fixup event stream (un)marshal event name to match model (#4261
Browse files Browse the repository at this point in the history
)

Updates SDK's code generation for even stream event names to match the member's modeled name. Fixes the SDK not using the right case or name if the modeled name is not Go exportable name.
  • Loading branch information
jasdel committed Jan 27, 2022
1 parent 5bcaccb commit fdd6541
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
Expand Up @@ -67,13 +67,13 @@
"type":"structure",
"members":{
"Headers":{"shape":"HeaderOnlyEvent"},
"ImplicitPayload":{"shape":"ImplicitPayloadEvent"},
"implicitPayload":{"shape":"ImplicitPayloadEvent"},
"ExplicitPayload":{"shape":"ExplicitPayloadEvent"},
"PayloadOnly":{"shape":"PayloadOnlyEvent"},
"payloadOnly":{"shape":"PayloadOnlyEvent"},
"PayloadOnlyBlob":{"shape":"PayloadOnlyBlobEvent"},
"PayloadOnlyString":{"shape":"PayloadOnlyStringEvent"},
"payloadOnlyString":{"shape":"PayloadOnlyStringEvent"},
"Empty":{"shape":"EmptyEvent"},
"Exception":{"shape":"ExceptionEvent"},
"exception":{"shape":"ExceptionEvent"},
"Exception2":{"shape":"ExceptionEvent2"}
},
"eventstream":true
Expand Down
8 changes: 4 additions & 4 deletions private/model/api/codegentest/service/restjsonservice/api.go

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

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

7 changes: 6 additions & 1 deletion private/model/api/eventstream.go
Expand Up @@ -285,10 +285,15 @@ func setupEventStream(s *Shape) *EventStream {
}
eventRef.Shape.EventFor[eventStream.Name] = eventStream

eventName := eventRefName
if v := eventRef.LocationName; v != "" {
eventName = v
}

// Exceptions and events are two different lists to allow the SDK
// to easily generate code with the two handled differently.
event := &Event{
Name: eventRefName,
Name: eventName,
Shape: eventRef.Shape,
For: eventStream,
}
Expand Down

0 comments on commit fdd6541

Please sign in to comment.