Skip to content

Commit d17d7e2

Browse files
committed
Add RequestCompression trait
1 parent fde0d09 commit d17d7e2

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

Sources/SotoSmithy/Core/Smithy.swift

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public struct Smithy {
106106
PaginatedTrait.self,
107107
HttpChecksumRequiredTrait.self,
108108
HttpChecksumTrait.self,
109+
RequestCompression.self,
109110
// resource traits
110111
NoReplaceTrait.self,
111112
ReferencesTrait.self,

Sources/SotoSmithy/Traits/Types/BehaviourTraits.swift

+10
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,13 @@ public struct UnitTypeTrait: StaticTrait {
9191
public var selector: Selector { TypeSelector<UnitShape>() }
9292
public init() {}
9393
}
94+
95+
/// Defines the shape to be a unit type similar to Void or None
96+
public struct RequestCompression: StaticTrait {
97+
public static var staticName: ShapeId = "smithy.api#requestCompression"
98+
public var selector: Selector { TypeSelector<OperationShape>() }
99+
public let encodings: [String]
100+
public init(encodings: [String]) {
101+
self.encodings = encodings
102+
}
103+
}

Tests/SotoSmithyTests/TraitTests.swift

+25
Original file line numberDiff line numberDiff line change
@@ -465,4 +465,29 @@ class TraitTests: XCTestCase {
465465
let model = try Smithy().parse(smithy)
466466
try model.validate()
467467
}
468+
469+
func testRequestCompression() throws {
470+
let smithy = """
471+
$version: "2"
472+
namespace smithy.example
473+
474+
@requestCompression(
475+
encodings: ["gzip"]
476+
)
477+
operation PutWithContentEncoding {
478+
input: PutWithContentEncodingInput
479+
}
480+
481+
@input
482+
structure PutWithContentEncodingInput {
483+
@httpHeader("Content-Encoding")
484+
customEncoding: String // brotli
485+
486+
@httpPayload
487+
data: String
488+
}
489+
"""
490+
let model = try Smithy().parse(smithy)
491+
try model.validate()
492+
}
468493
}

0 commit comments

Comments
 (0)