Skip to content

Commit bd2c5db

Browse files
authored
fix: a few codegen fixes to compile the last 5 services not compiling (#266)
1 parent 20450ac commit bd2c5db

35 files changed

+307
-265
lines changed

Packages/ClientRuntime/Sources/Networking/Http/CRT/CRTClientEngine.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public class CRTClientEngine: HttpClientEngine {
145145

146146
public func close() {
147147
for (endpoint, value) in connectionPools {
148-
logger.debug("Connection to endpoint: \(endpoint.url?.absoluteString) is closing")
148+
logger.debug("Connection to endpoint: \(String(describing: endpoint.url?.absoluteString)) is closing")
149149
value.closePendingConnections()
150150
}
151151
}

Packages/ClientRuntime/Sources/Networking/StreamSink.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import class Foundation.FileManager
1010

1111
// TODO: handle backpressure more thoroughly to allow for indication that they are ready for more
1212
@available(*, message: "This streaming interface is unstable currently for dynamic streaming")
13-
public protocol StreamSink: class {
13+
public protocol StreamSink: AnyObject {
1414
func receiveData(readFrom buffer: ByteBuffer)
1515
func onError(error: StreamError)
1616
}

Packages/Package.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import PackageDescription
33
import class Foundation.ProcessInfo
44

5+
let excludes = ["README.md"]
6+
57
let package = Package(
68
name: "ClientRuntime",
79
platforms: [
@@ -24,7 +26,8 @@ let package = Package(
2426
.product(name: "Logging", package: "swift-log"),
2527
.product(name: "XMLCoder", package: "XMLCoder")
2628
],
27-
path: "./ClientRuntime/Sources"
29+
path: "./ClientRuntime/Sources",
30+
exclude: excludes
2831
),
2932
.testTarget(
3033
name: "ClientRuntimeTests",
@@ -37,7 +40,8 @@ let package = Package(
3740
.target(
3841
name: "SmithyTestUtil",
3942
dependencies: ["ClientRuntime"],
40-
path: "./SmithyTestUtil/Sources"
43+
path: "./SmithyTestUtil/Sources",
44+
exclude: excludes
4145
),
4246
.testTarget(
4347
name: "SmithyTestUtilTests",

smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/AddOperationShapes.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ class AddOperationShapes {
5252
.map { shapeId ->
5353
cloneOperationShape(
5454
operationId, (model.expectShape(shapeId) as StructureShape),
55-
"Output"
55+
"OutputResponse"
5656
)
5757
}
58-
.orElseGet { emptyOperationStructure(operationId, "Output", moduleName) }
58+
.orElseGet { emptyOperationStructure(operationId, "OutputResponse", moduleName) }
5959

6060
// Add new input/output to model
6161
modelBuilder.addShape(inputShape)

smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/MiddlewareGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class MiddlewareGenerator(
5454
writer.write("")
5555
writer.write("public typealias MInput = ${middleware.inputType.name}")
5656
writer.write("public typealias MOutput = ${middleware.outputType.name}")
57-
writer.write("public typealias Context = ${middleware.contextType.name}")
57+
writer.write("public typealias Context = ClientRuntime.${middleware.contextType.name}")
5858
writer.write("public typealias MError = ${middleware.errorType.name}")
5959
}
6060
}

smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/StructureGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ class StructureGenerator(
210210
val httpErrorTrait = shape.getTrait<HttpErrorTrait>()
211211
val hasErrorTrait = httpErrorTrait != null || errorTrait != null
212212
if (hasErrorTrait) {
213-
writer.write("public var _headers: Headers?")
213+
writer.write("public var _headers: ClientRuntime.Headers?")
214214
writer.write("public var _statusCode: HttpStatusCode?")
215215
}
216216
writer.write("public var _message: String?")

smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/httpResponse/bindingTraits/HttpResponseTraitWithoutHttpPayload.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,23 @@ class HttpResponseTraitWithoutHttpPayload(
3535

3636
val bodyMembersWithoutQueryTrait = bodyMembers
3737
.filter { !it.member.hasTrait(HttpQueryTrait::class.java) }
38-
.map { ctx.symbolProvider.toMemberName(it.member) }
3938
.toMutableSet()
4039

40+
val bodyMembersWithoutQueryTraitMemberNames = bodyMembersWithoutQueryTrait.map { ctx.symbolProvider.toMemberName(it.member) }
41+
4142
if (bodyMembersWithoutQueryTrait.isNotEmpty()) {
4243
writer.write("if case .data(let data) = httpResponse.body,")
4344
writer.indent()
4445
writer.write("let unwrappedData = data,")
4546
writer.write("let responseDecoder = decoder {")
4647
writer.write("let output: ${outputShapeName}Body = try responseDecoder.decode(responseBody: unwrappedData)")
47-
bodyMembersWithoutQueryTrait.sorted().forEach {
48+
bodyMembersWithoutQueryTraitMemberNames.sorted().forEach {
4849
writer.write("self.$it = output.$it")
4950
}
5051
writer.dedent()
5152
writer.write("} else {")
5253
writer.indent()
53-
bodyMembers.sortedBy { it.memberName }.forEach {
54+
bodyMembersWithoutQueryTrait.sortedBy { it.memberName }.forEach {
5455
val memberName = ctx.symbolProvider.toMemberName(it.member)
5556
val type = ctx.model.expectShape(it.member.target)
5657
val value = if (ctx.symbolProvider.toSymbol(it.member).isBoxed()) "nil" else {

smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/json/MemberShapeDecodeGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ abstract class MemberShapeDecodeGenerator(
154154
}
155155
renderAssigningDecodedMember(topLevelMember, decodedMemberName)
156156
} else {
157-
val isBoxed = ctx.symbolProvider.toSymbol(nestedTarget).isBoxed()
157+
val isBoxed = originalSymbol.isBoxed()
158158
if (isBoxed) {
159159
writer.openBlock("if let \$L = \$L {", "}", memberName, memberName) {
160160
renderDecodeListTarget(nestedTarget, containerName, memberName, insertMethod, topLevelMember, level)

smithy-swift-codegen/src/test/kotlin/HttpBindingProtocolGeneratorTests.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ class HttpBindingProtocolGeneratorTests {
6565

6666
@Test
6767
fun `it creates correct init for explicit struct payloads`() {
68-
val contents = getModelFileContents("example", "ExplicitStructOutput+HttpResponseBinding.swift", newTestContext.manifest)
68+
val contents = getModelFileContents("example", "ExplicitStructOutputResponse+HttpResponseBinding.swift", newTestContext.manifest)
6969
contents.shouldSyntacticSanityCheck()
7070
val expectedContents =
7171
"""
72-
extension ExplicitStructOutput: HttpResponseBinding {
72+
extension ExplicitStructOutputResponse: HttpResponseBinding {
7373
public init (httpResponse: HttpResponse, decoder: ResponseDecoder? = nil) throws {
7474
if case .data(let data) = httpResponse.body,
7575
let unwrappedData = data {
@@ -96,12 +96,12 @@ extension ExplicitStructOutput: HttpResponseBinding {
9696
}
9797

9898
@Test
99-
fun `httpResponseCodeOutput response init content`() {
100-
val contents = getModelFileContents("example", "HttpResponseCodeOutput+HttpResponseBinding.swift", newTestContext.manifest)
99+
fun `httpResponseCodeOutputResponse response init content`() {
100+
val contents = getModelFileContents("example", "HttpResponseCodeOutputResponse+HttpResponseBinding.swift", newTestContext.manifest)
101101
contents.shouldSyntacticSanityCheck()
102102
val expectedContents =
103103
"""
104-
extension HttpResponseCodeOutput: HttpResponseBinding {
104+
extension HttpResponseCodeOutputResponse: HttpResponseBinding {
105105
public init (httpResponse: HttpResponse, decoder: ResponseDecoder? = nil) throws {
106106
self.status = httpResponse.statusCode.rawValue
107107
}
@@ -112,11 +112,11 @@ extension HttpResponseCodeOutput: HttpResponseBinding {
112112

113113
@Test
114114
fun `decode the document type in HttpResponseBinding`() {
115-
val contents = getModelFileContents("example", "InlineDocumentAsPayloadOutput+HttpResponseBinding.swift", newTestContext.manifest)
115+
val contents = getModelFileContents("example", "InlineDocumentAsPayloadOutputResponse+HttpResponseBinding.swift", newTestContext.manifest)
116116
contents.shouldSyntacticSanityCheck()
117117
val expectedContents =
118118
"""
119-
extension InlineDocumentAsPayloadOutput: HttpResponseBinding {
119+
extension InlineDocumentAsPayloadOutputResponse: HttpResponseBinding {
120120
public init (httpResponse: HttpResponse, decoder: ResponseDecoder? = nil) throws {
121121
if case .data(let data) = httpResponse.body,
122122
let unwrappedData = data {
@@ -136,10 +136,10 @@ extension InlineDocumentAsPayloadOutput: HttpResponseBinding {
136136
}
137137
@Test
138138
fun `default fooMap to an empty map if keysForFooMap is empty`() {
139-
val contents = getModelFileContents("example", "HttpPrefixHeadersOutput+HttpResponseBinding.swift", newTestContext.manifest)
139+
val contents = getModelFileContents("example", "HttpPrefixHeadersOutputResponse+HttpResponseBinding.swift", newTestContext.manifest)
140140
val expectedContents =
141141
"""
142-
extension HttpPrefixHeadersOutput: HttpResponseBinding {
142+
extension HttpPrefixHeadersOutputResponse: HttpResponseBinding {
143143
public init (httpResponse: HttpResponse, decoder: ResponseDecoder? = nil) throws {
144144
if let fooHeaderValue = httpResponse.headers.value(for: "X-Foo") {
145145
self.foo = fooHeaderValue

smithy-swift-codegen/src/test/kotlin/HttpBodyMiddlewareTests.kt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class HttpBodyMiddlewareTests {
3232
3333
public func handle<H>(context: Context,
3434
input: SerializeStepInput<SmokeTestInput>,
35-
next: H) -> Swift.Result<OperationOutput<SmokeTestOutput>, MError>
35+
next: H) -> Swift.Result<OperationOutput<SmokeTestOutputResponse>, MError>
3636
where H: Handler,
3737
Self.MInput == H.Input,
3838
Self.MOutput == H.Output,
@@ -53,8 +53,8 @@ class HttpBodyMiddlewareTests {
5353
}
5454
5555
public typealias MInput = SerializeStepInput<SmokeTestInput>
56-
public typealias MOutput = OperationOutput<SmokeTestOutput>
57-
public typealias Context = HttpContext
56+
public typealias MOutput = OperationOutput<SmokeTestOutputResponse>
57+
public typealias Context = ClientRuntime.HttpContext
5858
public typealias MError = SdkError<SmokeTestOutputError>
5959
}
6060
""".trimIndent()
@@ -74,7 +74,7 @@ class HttpBodyMiddlewareTests {
7474
7575
public func handle<H>(context: Context,
7676
input: SerializeStepInput<ExplicitStringInput>,
77-
next: H) -> Swift.Result<OperationOutput<ExplicitStringOutput>, MError>
77+
next: H) -> Swift.Result<OperationOutput<ExplicitStringOutputResponse>, MError>
7878
where H: Handler,
7979
Self.MInput == H.Input,
8080
Self.MOutput == H.Output,
@@ -90,8 +90,8 @@ class HttpBodyMiddlewareTests {
9090
}
9191
9292
public typealias MInput = SerializeStepInput<ExplicitStringInput>
93-
public typealias MOutput = OperationOutput<ExplicitStringOutput>
94-
public typealias Context = HttpContext
93+
public typealias MOutput = OperationOutput<ExplicitStringOutputResponse>
94+
public typealias Context = ClientRuntime.HttpContext
9595
public typealias MError = SdkError<ExplicitStringOutputError>
9696
}
9797
""".trimIndent()
@@ -111,7 +111,7 @@ class HttpBodyMiddlewareTests {
111111
112112
public func handle<H>(context: Context,
113113
input: SerializeStepInput<ExplicitBlobInput>,
114-
next: H) -> Swift.Result<OperationOutput<ExplicitBlobOutput>, MError>
114+
next: H) -> Swift.Result<OperationOutput<ExplicitBlobOutputResponse>, MError>
115115
where H: Handler,
116116
Self.MInput == H.Input,
117117
Self.MOutput == H.Output,
@@ -127,8 +127,8 @@ class HttpBodyMiddlewareTests {
127127
}
128128
129129
public typealias MInput = SerializeStepInput<ExplicitBlobInput>
130-
public typealias MOutput = OperationOutput<ExplicitBlobOutput>
131-
public typealias Context = HttpContext
130+
public typealias MOutput = OperationOutput<ExplicitBlobOutputResponse>
131+
public typealias Context = ClientRuntime.HttpContext
132132
public typealias MError = SdkError<ExplicitBlobOutputError>
133133
}
134134
""".trimIndent()
@@ -148,7 +148,7 @@ class HttpBodyMiddlewareTests {
148148
149149
public func handle<H>(context: Context,
150150
input: SerializeStepInput<ExplicitBlobStreamInput>,
151-
next: H) -> Swift.Result<OperationOutput<ExplicitBlobStreamOutput>, MError>
151+
next: H) -> Swift.Result<OperationOutput<ExplicitBlobStreamOutputResponse>, MError>
152152
where H: Handler,
153153
Self.MInput == H.Input,
154154
Self.MOutput == H.Output,
@@ -164,8 +164,8 @@ class HttpBodyMiddlewareTests {
164164
}
165165
166166
public typealias MInput = SerializeStepInput<ExplicitBlobStreamInput>
167-
public typealias MOutput = OperationOutput<ExplicitBlobStreamOutput>
168-
public typealias Context = HttpContext
167+
public typealias MOutput = OperationOutput<ExplicitBlobStreamOutputResponse>
168+
public typealias Context = ClientRuntime.HttpContext
169169
public typealias MError = SdkError<ExplicitBlobStreamOutputError>
170170
}
171171
""".trimIndent()
@@ -185,7 +185,7 @@ class HttpBodyMiddlewareTests {
185185
186186
public func handle<H>(context: Context,
187187
input: SerializeStepInput<ExplicitStructInput>,
188-
next: H) -> Swift.Result<OperationOutput<ExplicitStructOutput>, MError>
188+
next: H) -> Swift.Result<OperationOutput<ExplicitStructOutputResponse>, MError>
189189
where H: Handler,
190190
Self.MInput == H.Input,
191191
Self.MOutput == H.Output,
@@ -206,8 +206,8 @@ class HttpBodyMiddlewareTests {
206206
}
207207
208208
public typealias MInput = SerializeStepInput<ExplicitStructInput>
209-
public typealias MOutput = OperationOutput<ExplicitStructOutput>
210-
public typealias Context = HttpContext
209+
public typealias MOutput = OperationOutput<ExplicitStructOutputResponse>
210+
public typealias Context = ClientRuntime.HttpContext
211211
public typealias MError = SdkError<ExplicitStructOutputError>
212212
}
213213
""".trimIndent()

0 commit comments

Comments
 (0)