From aacff71dd8eb31cc9c67cf9cf0be69fa43279195 Mon Sep 17 00:00:00 2001 From: Chan <55515281+sichanyoo@users.noreply.github.com> Date: Fri, 6 Sep 2024 12:49:14 -0700 Subject: [PATCH] feat: Add default trait support (#1696) * Don't add x-amz-content-sha256 header before request is handed off to CRT signer. * Enable protocol tests that use defaults tag again. * swiftlint --------- Co-authored-by: Sichan Yoo --- .../Middlewares/Sha256TreeHashMiddleware.swift | 10 ++-------- .../AWSClientRuntime/UserAgent/BusinessMetrics.swift | 4 ++-- .../protocols/awsjson/AWSJSON1_0ProtocolGenerator.kt | 1 - .../protocols/awsjson/AWSJSON1_1ProtocolGenerator.kt | 1 - .../protocols/awsquery/AWSQueryProtocolGenerator.kt | 1 - .../protocols/ec2query/EC2QueryProtocolGenerator.kt | 1 - .../restjson/AWSRestJson1ProtocolGenerator.kt | 3 ++- .../protocols/restxml/RestXMLProtocolGenerator.kt | 1 - 8 files changed, 6 insertions(+), 16 deletions(-) diff --git a/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Middlewares/Sha256TreeHashMiddleware.swift b/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Middlewares/Sha256TreeHashMiddleware.swift index 475214d14a8..f2578c78c83 100644 --- a/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Middlewares/Sha256TreeHashMiddleware.swift +++ b/Sources/Core/AWSClientRuntime/Sources/AWSClientRuntime/Middlewares/Sha256TreeHashMiddleware.swift @@ -24,14 +24,8 @@ public struct Sha256TreeHashMiddleware>(name: " "SIGV4A_SIGNING" : "S" : Y "RESOLVED_ACCOUNT_ID" : "T" : */ -fileprivate func setFlagsIntoContext( +private func setFlagsIntoContext( config: UserAgentValuesFromConfig, context: Context ) { diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/awsjson/AWSJSON1_0ProtocolGenerator.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/awsjson/AWSJSON1_0ProtocolGenerator.kt index 73c99408234..e1506fd9dc4 100644 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/awsjson/AWSJSON1_0ProtocolGenerator.kt +++ b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/awsjson/AWSJSON1_0ProtocolGenerator.kt @@ -23,7 +23,6 @@ class AWSJSON1_0ProtocolGenerator : AWSHTTPBindingProtocolGenerator(AWSJSONCusto "SDKAppliedContentEncoding_awsJson1_0", "SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsJson1_0", ) - override val tagsToIgnore = setOf("defaults") override fun getProtocolHttpBindingResolver(ctx: ProtocolGenerator.GenerationContext, defaultContentType: String): HttpBindingResolver = AWSJSONHttpBindingResolver(ctx, defaultContentType) diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/awsjson/AWSJSON1_1ProtocolGenerator.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/awsjson/AWSJSON1_1ProtocolGenerator.kt index 49ed1c92b5b..fa4cf34548b 100644 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/awsjson/AWSJSON1_1ProtocolGenerator.kt +++ b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/awsjson/AWSJSON1_1ProtocolGenerator.kt @@ -23,7 +23,6 @@ class AWSJSON1_1ProtocolGenerator : AWSHTTPBindingProtocolGenerator(AWSJSONCusto "SDKAppliedContentEncoding_awsJson1_1", "SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsJson1_1", ) - override val tagsToIgnore = setOf("defaults") override fun getProtocolHttpBindingResolver(ctx: ProtocolGenerator.GenerationContext, defaultContentType: String): HttpBindingResolver = AWSJSONHttpBindingResolver(ctx, defaultContentType) diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/awsquery/AWSQueryProtocolGenerator.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/awsquery/AWSQueryProtocolGenerator.kt index 3d57de640bc..6b90e716075 100644 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/awsquery/AWSQueryProtocolGenerator.kt +++ b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/awsquery/AWSQueryProtocolGenerator.kt @@ -27,7 +27,6 @@ open class AWSQueryProtocolGenerator : AWSHTTPBindingProtocolGenerator(AWSQueryC "SDKAppliedContentEncoding_awsQuery", "SDKAppendsGzipAndIgnoresHttpProvidedEncoding_awsQuery", ) - override val tagsToIgnore = setOf("defaults") override fun addProtocolSpecificMiddleware(ctx: ProtocolGenerator.GenerationContext, operation: OperationShape) { super.addProtocolSpecificMiddleware(ctx, operation) diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/ec2query/EC2QueryProtocolGenerator.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/ec2query/EC2QueryProtocolGenerator.kt index 2c063c2dc82..449ad111070 100644 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/ec2query/EC2QueryProtocolGenerator.kt +++ b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/ec2query/EC2QueryProtocolGenerator.kt @@ -27,7 +27,6 @@ class EC2QueryProtocolGenerator : AWSHTTPBindingProtocolGenerator(EC2QueryCustom "SDKAppliedContentEncoding_ec2Query", "SDKAppendsGzipAndIgnoresHttpProvidedEncoding_ec2Query" ) - override val tagsToIgnore = setOf("defaults") override fun addProtocolSpecificMiddleware(ctx: ProtocolGenerator.GenerationContext, operation: OperationShape) { super.addProtocolSpecificMiddleware(ctx, operation) diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/restjson/AWSRestJson1ProtocolGenerator.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/restjson/AWSRestJson1ProtocolGenerator.kt index 3be167efcd1..09759764ae8 100644 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/restjson/AWSRestJson1ProtocolGenerator.kt +++ b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/restjson/AWSRestJson1ProtocolGenerator.kt @@ -14,6 +14,7 @@ class AWSRestJson1ProtocolGenerator : AWSHTTPBindingProtocolGenerator(RestJSONCu override val testsToIgnore = setOf( "SDKAppliedContentEncoding_restJson1", "SDKAppendedGzipAfterProvidedEncoding_restJson1", + // This test is disabled until Smithy v1.51.0 with the fix for the test gets released. + "RestJsonClientIgnoresDefaultValuesIfMemberValuesArePresentInResponse" ) - override val tagsToIgnore = setOf("defaults") } diff --git a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/restxml/RestXMLProtocolGenerator.kt b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/restxml/RestXMLProtocolGenerator.kt index 29dfe85296f..360f3ff15e4 100644 --- a/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/restxml/RestXMLProtocolGenerator.kt +++ b/codegen/smithy-aws-swift-codegen/src/main/kotlin/software/amazon/smithy/aws/swift/codegen/protocols/restxml/RestXMLProtocolGenerator.kt @@ -27,7 +27,6 @@ class RestXMLProtocolGenerator : AWSHTTPBindingProtocolGenerator(RestXMLCustomiz "S3PreservesEmbeddedDotSegmentInUriLabel", // moved to s3-tests.smithy "S3PreservesLeadingDotSegmentInUriLabel", // moved to s3-tests.smithy ) - override val tagsToIgnore = setOf("defaults") override fun generateDeserializers(ctx: ProtocolGenerator.GenerationContext) { super.generateDeserializers(ctx)