-
Notifications
You must be signed in to change notification settings - Fork 237
Fixing bug with enums as eventHeaders #4337
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
8d810d2
038c6cc
532f87e
60d06cd
9a79b66
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 |
|---|---|---|
|
|
@@ -21,8 +21,11 @@ private fun fillInBaseModel( | |
| namespacedProtocolName: String, | ||
| extraServiceAnnotations: String = "", | ||
| nonEventStreamMembers: String = "", | ||
| extraEventHeaderMembers: String = "", | ||
| extraShapes: String = "", | ||
| ): String = | ||
| """ | ||
| ${"\$version: \"2\""} | ||
| namespace test | ||
|
|
||
| use smithy.framework#ValidationException | ||
|
|
@@ -42,6 +45,8 @@ private fun fillInBaseModel( | |
| Message: String, | ||
| } | ||
|
|
||
| $extraShapes | ||
|
|
||
| structure MessageWithBlob { @eventPayload data: Blob } | ||
| structure MessageWithString { @eventPayload data: String } | ||
| structure MessageWithStruct { @eventPayload someStruct: TestStruct } | ||
|
|
@@ -55,6 +60,7 @@ private fun fillInBaseModel( | |
| @eventHeader short: Short, | ||
| @eventHeader string: String, | ||
| @eventHeader timestamp: Timestamp, | ||
| $extraEventHeaderMembers | ||
| } | ||
| structure MessageWithHeaderAndPayload { | ||
| @eventHeader header: String, | ||
|
|
@@ -129,6 +135,26 @@ object EventStreamTestModels { | |
|
|
||
| fun withNonEventStreamMembers(nonEventStreamMembers: String): TestCase = | ||
| this.copy(model = fillInBaseModel(this.protocolShapeId, "", nonEventStreamMembers).asSmithyModel()) | ||
|
|
||
| // Server doesn't support enum members in event streams, so this util allows Clients to test with those shapes | ||
| fun withEnumMembers(): TestCase = | ||
| this.copy( | ||
| model = | ||
| fillInBaseModel( | ||
| this.protocolShapeId, | ||
| extraEventHeaderMembers = "@eventHeader enum: TheEnum,\n@eventHeader intEnum: FaceCard,", | ||
| extraShapes = """ enum TheEnum { | ||
| FOO | ||
| BAR | ||
| } | ||
|
|
||
| intEnum FaceCard { | ||
|
Contributor
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. Do we support intEnum yet? #1700
Contributor
Author
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. No, but I still think this should stay in the test so that when we do support them we get an obvious test failure if they don't work as |
||
| JACK = 1 | ||
| QUEEN = 2 | ||
| KING = 3 | ||
| }""", | ||
| ).asSmithyModel(), | ||
| ) | ||
| } | ||
|
|
||
| private fun base64Encode(input: ByteArray): String { | ||
|
|
||
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.
does this handle
intEnum?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.
I don't think any codegen actually supports
intEnum(see #1700) so it isn't handled here. I did add it to the test model though so when we do support it we will get an obvious error in these tests if it doesn't work as an@eventHeader.