Skip to content

chore: Update Smithy to 1.59.0 #937

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions Sources/SmithyHTTPAPI/Headers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to avoid simultaneously holding two locks.

}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kotlin.code.style=official
# config

# codegen
smithyVersion=1.54.0
smithyVersion=1.59.0
smithyGradleVersion=0.6.0

# kotlin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We were incorrectly rendering the expected value when a collection or aggregate shape when it is supposed to be absent (i.e. "null" in the Smithy node tree for expected value.) This if-else handles that case.

val nodeVisitor = ShapeValueNodeVisitor(writer, this, shape)

when (shape.type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
Copy link
Contributor Author

@jbelkins jbelkins Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reformat

writer.write("EndpointParams(\$L)", params.joinToString(", "))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New protocol tests specify that specific headers bound to names can overwrite prefix headers. This guard creates that behavior.

if (mapValueShapeTarget is CollectionShape) {
writer.openBlock("prefixHeaderMapValue.forEach { headerValue in ", "}") {
if (mapValueShapeTargetSymbol.isBoxed()) {
Expand Down
Loading