-
Notifications
You must be signed in to change notification settings - Fork 31
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
feat!: Closure-based reader-writer serde for JSON, FormURL #696
Changes from 1 commit
3ee7e8d
0a6cbb5
255be51
ef6afbc
1b71f03
1042248
e4958ba
b6ea1d8
e2d41a6
7bb92f5
9d8090f
c0be78e
70eb9c7
9049fbf
7766c88
d8511a3
ce56c31
a6f6a96
d8158b5
0d3ebf1
0cb4b04
6ada476
7655987
23248ea
19fb75d
77ac55f
8b4212f
efdabef
54498c3
73b1ae3
3ec9818
74051e3
ecd9c94
9b643b8
a76bed8
a2f8612
975c2d6
a3caac2
05ecd95
b1d6f94
9a2a983
7ca1ebf
70f18e1
12f1ed1
9ffbd39
8a4df3e
cf6b8ab
126195e
39e539b
c8c6aa2
84721ae
6eef981
05d6d33
3bd83cc
042b734
532977b
0a35bdf
3bd533a
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 |
---|---|---|
|
@@ -86,6 +86,7 @@ class HTTPResponseTraitWithHTTPPayload( | |
ShapeType.STRUCTURE, ShapeType.UNION -> { | ||
if (target.hasTrait<StreamingTrait>()) { | ||
writer.openBlock("if case .stream(let stream) = httpResponse.body {", "}") { | ||
writer.addImport(customizations.messageDecoderSymbol.namespace) | ||
writer.write("let messageDecoder = \$N()", customizations.messageDecoderSymbol) | ||
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 message decoder type is read from the customizations, instead of using a section writer which is super confusing and carries a lot of extra weight elsewhere in the code. |
||
writer.write( | ||
"let decoderStream = \$N(stream: stream, messageDecoder: messageDecoder, unmarshalClosure: \$N.unmarshal)", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,7 @@ class HTTPResponseTraitWithoutHTTPPayload( | |
when (shape.type) { | ||
ShapeType.UNION -> { | ||
writer.openBlock("if case let .stream(stream) = httpResponse.body {", "}") { | ||
writer.addImport(customizations.messageDecoderSymbol.namespace) | ||
writer.write("let messageDecoder = \$N()", customizations.messageDecoderSymbol) | ||
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. Once again, customizations are used for message decoder type instead of a section writer. |
||
writer.write( | ||
"let decoderStream = \$L<\$N>(stream: stream, messageDecoder: messageDecoder, unmarshalClosure: \$N.unmarshal)", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,7 +157,7 @@ class OperationInputBodyMiddleware( | |
|
||
private fun addEventStreamMiddleware(writer: SwiftWriter, operationStackName: String, inputSymbol: Symbol, outputSymbol: Symbol, payloadSymbol: Symbol, keyPath: String, defaultBody: String, requestWireProtocol: WireProtocol, sendInitialRequest: Boolean) { | ||
if (sendInitialRequest) { | ||
writer.write("let initialRequestMessage = try input.makeInitialRequestMessage(encoder: encoder)") | ||
writer.write("let initialRequestMessage = try input.makeInitialRequestMessage()") | ||
} | ||
writer.write( | ||
"\$L.\$L.intercept(position: \$L, middleware: \$N<\$N, \$N, \$N>(keyPath: \$L, defaultBody: \$L, marshalClosure: \$N.marshal\$L))", | ||
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. Types now supply their own marshal closure as a static property |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,17 +41,18 @@ class InitialRequestIntegration : SwiftIntegration { | |
.build() | ||
protocolGenerationContext.delegator.useShapeWriter(inputStruct) { writer -> | ||
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. Code updated for new method signatures |
||
writer.apply { | ||
addImport(SwiftDependency.CLIENT_RUNTIME.target) | ||
openBlock("extension ${symbol.fullName} {", "}") { | ||
addImport(protocolGenerationContext.service.writerSymbol.namespace) | ||
openBlock("extension \$N {", "}", symbol) { | ||
writer.addImport(SwiftDependency.CLIENT_RUNTIME.target) | ||
openBlock( | ||
"func makeInitialRequestMessage(encoder: ClientRuntime.RequestEncoder) throws -> EventStream.Message {", | ||
"func makeInitialRequestMessage() throws -> EventStream.Message {", | ||
"}" | ||
) { | ||
val nodeInfoUtils = NodeInfoUtils(protocolGenerationContext, writer, protocolGenerationContext.service.requestWireProtocol) | ||
val rootNodeInfo = nodeInfoUtils.nodeInfo(it, true) | ||
val valueWritingClosure = WritingClosureUtils(protocolGenerationContext, writer).writingClosure(it) | ||
writer.write("let writer = \$N(nodeInfo: \$L)", protocolGenerationContext.service.writerSymbol, rootNodeInfo) | ||
writer.write("try writer.write(self, writingClosure: \$L)", valueWritingClosure) | ||
writer.write("try writer.write(self, with: \$L)", valueWritingClosure) | ||
writer.write("let initialRequestPayload = try writer.data()") | ||
openBlock( | ||
"let initialRequestMessage = EventStream.Message(", | ||
|
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.
Delete factory since there is now only one implementation