Skip to content

Commit

Permalink
Add RequestCompression trait
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Feb 19, 2024
1 parent fde0d09 commit d17d7e2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions Sources/SotoSmithy/Core/Smithy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public struct Smithy {
PaginatedTrait.self,
HttpChecksumRequiredTrait.self,
HttpChecksumTrait.self,
RequestCompression.self,
// resource traits
NoReplaceTrait.self,
ReferencesTrait.self,
Expand Down
10 changes: 10 additions & 0 deletions Sources/SotoSmithy/Traits/Types/BehaviourTraits.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,13 @@ public struct UnitTypeTrait: StaticTrait {
public var selector: Selector { TypeSelector<UnitShape>() }
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<OperationShape>() }
public let encodings: [String]
public init(encodings: [String]) {
self.encodings = encodings
}
}
25 changes: 25 additions & 0 deletions Tests/SotoSmithyTests/TraitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

0 comments on commit d17d7e2

Please sign in to comment.