diff --git a/Sources/SotoSmithy/Core/Smithy.swift b/Sources/SotoSmithy/Core/Smithy.swift index aadbe77..50a7351 100644 --- a/Sources/SotoSmithy/Core/Smithy.swift +++ b/Sources/SotoSmithy/Core/Smithy.swift @@ -106,6 +106,7 @@ public struct Smithy { PaginatedTrait.self, HttpChecksumRequiredTrait.self, HttpChecksumTrait.self, + RequestCompression.self, // resource traits NoReplaceTrait.self, ReferencesTrait.self, diff --git a/Sources/SotoSmithy/Traits/Types/BehaviourTraits.swift b/Sources/SotoSmithy/Traits/Types/BehaviourTraits.swift index faa42c6..460bb64 100644 --- a/Sources/SotoSmithy/Traits/Types/BehaviourTraits.swift +++ b/Sources/SotoSmithy/Traits/Types/BehaviourTraits.swift @@ -91,3 +91,13 @@ public struct UnitTypeTrait: StaticTrait { public var selector: Selector { TypeSelector() } public init() {} } + +/// Defines the shape to be a unit type similar to Void or None +public struct RequestCompression: StaticTrait { + public static var staticName: ShapeId = "smithy.api#requestCompression" + public var selector: Selector { TypeSelector() } + public let encodings: [String] + public init(encodings: [String]) { + self.encodings = encodings + } +} diff --git a/Tests/SotoSmithyTests/TraitTests.swift b/Tests/SotoSmithyTests/TraitTests.swift index 6da972c..b35a1c7 100644 --- a/Tests/SotoSmithyTests/TraitTests.swift +++ b/Tests/SotoSmithyTests/TraitTests.swift @@ -465,4 +465,29 @@ class TraitTests: XCTestCase { let model = try Smithy().parse(smithy) try model.validate() } + + func testRequestCompression() throws { + let smithy = """ + $version: "2" + namespace smithy.example + + @requestCompression( + encodings: ["gzip"] + ) + operation PutWithContentEncoding { + input: PutWithContentEncodingInput + } + + @input + structure PutWithContentEncodingInput { + @httpHeader("Content-Encoding") + customEncoding: String // brotli + + @httpPayload + data: String + } + """ + let model = try Smithy().parse(smithy) + try model.validate() + } }