-
Notifications
You must be signed in to change notification settings - Fork 30
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
chore: Move event marshal/unmarshal code to smithy-swift #728
Conversation
…ator in from aws-sdk-swift
@@ -0,0 +1,204 @@ | |||
package software.amazon.smithy.swift.codegen.events |
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.
Other than this package statement, this file is unchanged from how it was in aws-sdk-swift
.
|
||
class MessageUnmarshallableGenerator( | ||
val ctx: ProtocolGenerator.GenerationContext, | ||
val customizations: HTTPProtocolCustomizable, |
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.
This class now takes customizations as a parameter, so that the unknown error type can be passed in by the calling protocol.
writer.write("let httpResponse = HttpResponse(body: .data(message.payload), statusCode: .ok)") | ||
writer.write( | ||
"return \$L(httpResponse: httpResponse, message: \"error processing event stream, unrecognized ':exceptionType': \\(params.exceptionType); contentType: \\(params.contentType ?? \"nil\")\", requestID: nil, typeName: nil)", | ||
customizations.unknownServiceErrorSymbol, |
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.
The unknownServiceErrorSymbol
provided by customizations replaces the hard-coded reference to an AWS type so that this file can be moved to smithy-swift.
(Same change in one other place in this file)
@@ -484,9 +488,50 @@ abstract class HTTPBindingProtocolGenerator( | |||
return containedOperations | |||
} | |||
|
|||
abstract override fun generateMessageMarshallable(ctx: ProtocolGenerator.GenerationContext) |
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.
The 4 functions added in below are moved in unchanged from AWSHTTPBindingProtocolGenerator
.
contents.shouldContainOnlyOnce(expected) | ||
} | ||
|
||
private fun setupTests(smithyFile: String, serviceShapeId: String): TestContext { |
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.
This test setup was changed to use the smithy-swift test utils. The test expectations were adjusted because some of the generated types are now non-AWS types, and some non-AWS middlewares & other config are omitted.
|
||
override fun generateMessageUnmarshallable(ctx: ProtocolGenerator.GenerationContext) { | ||
TODO("Not yet implemented") | ||
} |
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.
These dummy implementations are removed so this protocol generator will actually render marshal/unmarshal code.
|
||
use aws.protocols#restJson1 | ||
use aws.api#service | ||
use aws.auth#sigv4 |
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.
This test Smithy file is entirely unchanged from SDK.
Description of changes
MessageMarshallableGenerator
andMessageUnmarshallableGenerator
fromaws-sdk-swift
tosmithy-swift
to support event streaming in non-AWS SDKs.AWSHTTPBindingProtocolGenerator
up to smithy-swift superclassHTTPBindingProtocolGenerator
.aws-sdk-swift
tosmithy-swift
.Scope
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.