Unverified Commit aaf75fbc authored by david-perez's avatar david-perez Committed by GitHub
Browse files

Remove TODO about required `httpHeader`-bound collection shapes (#1397)

We do support required `httpHeader`-bound collection shapes, as
evidenced by the test operation this commit adds, which is generated by
the server, that does not use `Option` for `required` member shapes.

This is because even though the deserialization always returns an
optional collection, we return `None` if no headers are found (as
opposed to an empty collection), so the call that sets the member field
on the operation structure does nothing; when `build()` gets called, a
`BuildError` is raised because the member is required.
parent 03b83473
Loading
Loading
Loading
Loading
+30 −5
Original line number Diff line number Diff line
@@ -14,7 +14,8 @@ use smithy.test#httpResponseTests
service MiscService {
    operations: [
        TypeComplexityOperation,
        InnerRequiredShapeOperation,
        RequiredInnerShapeOperation,
        RequiredHeaderCollectionOperation,
        ResponseCodeRequiredOperation,
        ResponseCodeHttpFallbackOperation,
        ResponseCodeDefaultOperation,
@@ -54,12 +55,12 @@ map MapA {
/// This operation tests that (de)serializing required values from a nested
/// shape works correctly.
@http(uri: "/innerRequiredShapeOperation", method: "POST")
operation InnerRequiredShapeOperation {
    input: InnerRequiredShapeOperationInputOutput,
    output: InnerRequiredShapeOperationInputOutput,
operation RequiredInnerShapeOperation {
    input: RequiredInnerShapeOperationInputOutput,
    output: RequiredInnerShapeOperationInputOutput,
}

structure InnerRequiredShapeOperationInputOutput {
structure RequiredInnerShapeOperationInputOutput {
    inner: InnerShape
}

@@ -230,3 +231,27 @@ structure ResponseCodeRequiredOutput {
    }
])
operation AcceptHeaderStarService {}

@http(uri: "/required-header-collection-operation", method: "GET")
operation RequiredHeaderCollectionOperation {
    input: RequiredHeaderCollectionOperationInputOutput,
    output: RequiredHeaderCollectionOperationInputOutput,
}

structure RequiredHeaderCollectionOperationInputOutput {
    @required
    @httpHeader("X-Required-List")
    requiredHeaderList: HeaderList,

    @required
    @httpHeader("X-Required-Set")
    requiredHeaderSet: HeaderSet,
}

list HeaderList {
    member: String
}

set HeaderSet {
    member: String
}
+0 −1
Original line number Diff line number Diff line
@@ -365,7 +365,6 @@ class HttpBindingGenerator(
                rust("let $parsedValue = $parsedValue?;")
            }
        }
        // TODO(https://github.com/awslabs/smithy-rs/issues/837): this doesn't support non-optional vectors
        when (rustType) {
            is RustType.Vec ->
                rust(