diff --git a/Sources/SmithyHTTPAPI/Headers.swift b/Sources/SmithyHTTPAPI/Headers.swift index bf9100359..40b52cdae 100644 --- a/Sources/SmithyHTTPAPI/Headers.swift +++ b/Sources/SmithyHTTPAPI/Headers.swift @@ -191,11 +191,9 @@ extension Headers: Equatable { /// - rhs: The second `Headers` to compare. /// - Returns: `true` if the two values are equal irrespective of order, otherwise `false`. public static func == (lhs: Headers, rhs: Headers) -> Bool { - lhs.access { lhsHeaders in - rhs.access { rhsHeaders in - lhsHeaders.sorted() == rhsHeaders.sorted() - } - } + let lhsHeaders = lhs.access { $0 }.sorted() + let rhsHeaders = rhs.access { $0 }.sorted() + return lhsHeaders == rhsHeaders } } diff --git a/gradle.properties b/gradle.properties index 563075c1d..ae8af99c5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ kotlin.code.style=official # config # codegen -smithyVersion=1.54.0 +smithyVersion=1.59.0 smithyGradleVersion=0.6.0 # kotlin diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/ShapeValueGenerator.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/ShapeValueGenerator.kt index 61d276df8..ede388fa7 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/ShapeValueGenerator.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/ShapeValueGenerator.kt @@ -10,6 +10,7 @@ import software.amazon.smithy.model.Model import software.amazon.smithy.model.node.ArrayNode import software.amazon.smithy.model.node.BooleanNode import software.amazon.smithy.model.node.Node +import software.amazon.smithy.model.node.NodeType import software.amazon.smithy.model.node.NodeVisitor import software.amazon.smithy.model.node.NullNode import software.amazon.smithy.model.node.NumberNode @@ -54,6 +55,13 @@ class ShapeValueGenerator( shape: Shape, params: Node, ) { + // If the node for the value to be written is NULL, then the value for this shape is not present. + // Just write a Swift `nil` and stop rendering. + if (params.type == NodeType.NULL) { + writer.writeInline("nil") + return + } + val nodeVisitor = ShapeValueNodeVisitor(writer, this, shape) when (shape.type) { diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/middlewares/OperationEndpointResolverMiddleware.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/middlewares/OperationEndpointResolverMiddleware.kt index 294094ae6..528ede514 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/middlewares/OperationEndpointResolverMiddleware.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/middlewares/OperationEndpointResolverMiddleware.kt @@ -112,8 +112,11 @@ open class OperationEndpointResolverMiddleware( } } } - - writer.openBlock("let endpointParamsBlock = { [config] (context: \$N) in", "}", SmithyTypes.Context) { + writer.openBlock( + "let endpointParamsBlock = { [config] (context: \$N) in", + "}", + SmithyTypes.Context, + ) { writer.write("EndpointParams(\$L)", params.joinToString(", ")) } } diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/middlewares/providers/HttpHeaderProvider.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/middlewares/providers/HttpHeaderProvider.kt index 84ea6369d..a6c88e298 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/middlewares/providers/HttpHeaderProvider.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/middlewares/providers/HttpHeaderProvider.kt @@ -180,6 +180,10 @@ class HttpHeaderProvider( val mapValueShapeTargetSymbol = ctx.symbolProvider.toSymbol(mapValueShapeTarget) writer.openBlock("for (prefixHeaderMapKey, prefixHeaderMapValue) in $memberName { ", "}") { + // Don't write a prefix header over a specific header that was also written to this request. + // See the HttpEmptyPrefixHeadersRequestClient protocol tests on the REST protocols. + writer.write("guard !items.exists(name: \"$paramName\\(prefixHeaderMapKey)\") else { continue }") + if (mapValueShapeTarget is CollectionShape) { writer.openBlock("prefixHeaderMapValue.forEach { headerValue in ", "}") { if (mapValueShapeTargetSymbol.isBoxed()) {