Skip to content

Commit

Permalink
Update codegen test & fix optional chaining.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sichan Yoo committed Nov 19, 2024
1 parent b9b7f18 commit eabc32e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@ private object FlexibleChecksumRequestMiddleware : MiddlewareRenderable {
val inputShapeName = MiddlewareShapeUtils.inputSymbol(ctx.symbolProvider, ctx.model, op).name
val outputShapeName = MiddlewareShapeUtils.outputSymbol(ctx.symbolProvider, ctx.model, op).name
val httpChecksumTrait = op.getTrait(HttpChecksumTrait::class.java).orElse(null)
val algorithmMemberName = httpChecksumTrait?.requestAlgorithmMember?.get()?.lowercaseFirstLetter()?.let {
val algorithmMemberName = httpChecksumTrait?.requestAlgorithmMember?.getOrNull()?.lowercaseFirstLetter()?.let {
"input.$it?.rawValue"
} ?: "nil"
val requestChecksumIsRequired = httpChecksumTrait?.isRequestChecksumRequired
val algoHeaderName = ctx.model.expectShape(op.inputShape).getMember(algorithmMemberName)?.getOrNull()?.getTrait<HttpHeaderTrait>()?.value?.let {
"\"$it\""
} ?: "nil"
val algoHeaderName = if (httpChecksumTrait?.requestAlgorithmMember?.getOrNull() != null) {
ctx.model.expectShape(op.inputShape).getMember(httpChecksumTrait.requestAlgorithmMember.get())?.getOrNull()?.getTrait<HttpHeaderTrait>()?.value?.let {
"\"$it\""
} ?: "nil"
} else { "nil" }

writer.write(
"\$N<\$L, \$L>(requestChecksumRequired: \$L, checksumAlgorithm: \$L, checksumAlgoHeaderName: \$L)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class FlexibleChecksumMiddlewareTests {
val contents = TestUtils.getFileContents(context.manifest, "Sources/Example/ChecksumTestsClient.swift")
contents.shouldSyntacticSanityCheck()
val expectedContents = """
builder.interceptors.add(AWSClientRuntime.FlexibleChecksumsRequestMiddleware<SomeOperationInput, SomeOperationOutput>(requestChecksumRequired: true, checksumAlgorithm: input.checksumAlgorithm?.rawValue))
builder.interceptors.add(AWSClientRuntime.FlexibleChecksumsRequestMiddleware<SomeOperationInput, SomeOperationOutput>(requestChecksumRequired: true, checksumAlgorithm: input.checksumAlgorithm?.rawValue, checksumAlgoHeaderName: "x-amz-request-algorithm"))
"""
contents.shouldContainOnlyOnce(expectedContents)
}
Expand Down

0 comments on commit eabc32e

Please sign in to comment.