Skip to content

Commit

Permalink
fix: temporarily handle httpchecksum trait the same as httpchecksumre…
Browse files Browse the repository at this point in the history
…quired (#608)
  • Loading branch information
ianbotsf authored Mar 22, 2022
1 parent 5732b83 commit 58d4642
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
package software.amazon.smithy.kotlin.codegen.rendering.protocol

import software.amazon.smithy.aws.traits.HttpChecksumTrait
import software.amazon.smithy.codegen.core.Symbol
import software.amazon.smithy.kotlin.codegen.core.*
import software.amazon.smithy.kotlin.codegen.integration.SectionId
Expand Down Expand Up @@ -248,7 +249,7 @@ abstract class HttpProtocolClientGenerator(
.forEach { middleware ->
middleware.render(ctx, op, writer)
}
if (op.hasTrait<HttpChecksumRequiredTrait>()) {
if (op.checksumRequired()) {
writer.addImport(RuntimeTypes.Http.Middlware.Md5ChecksumMiddleware)
writer.write("op.install(#T())", RuntimeTypes.Http.Middlware.Md5ChecksumMiddleware)
}
Expand All @@ -267,3 +268,7 @@ abstract class HttpProtocolClientGenerator(
*/
protected open fun renderAdditionalMethods(writer: KotlinWriter) { }
}

// TODO https://github.com/awslabs/aws-sdk-kotlin/issues/557
private fun OperationShape.checksumRequired(): Boolean =
hasTrait<HttpChecksumRequiredTrait>() || getTrait<HttpChecksumTrait>()?.isRequestChecksumRequired == true

0 comments on commit 58d4642

Please sign in to comment.