From b4ba0ad128eeba74ddb420c1b2ac56f188c34de4 Mon Sep 17 00:00:00 2001 From: Josh Elkins Date: Thu, 19 Dec 2024 15:14:13 -0600 Subject: [PATCH] chore: Update to Smithy 1.53.0 (#866) --- gradle.properties | 2 +- .../amazon/smithy/swift/codegen/ShapeValueGenerator.kt | 8 +++++--- .../amazon/smithy/swift/codegen/SwiftSymbolProvider.kt | 4 ++-- .../serde/member/MemberShapeDecodeGenerator.kt | 10 ++++++---- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/gradle.properties b/gradle.properties index 0fddf21da..d6f7479d7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ kotlin.code.style=official # config # codegen -smithyVersion=1.52.1 +smithyVersion=1.53.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 673da8e55..e5b7ec7ed 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 @@ -28,6 +28,7 @@ import software.amazon.smithy.model.traits.EnumTrait import software.amazon.smithy.model.traits.StreamingTrait import software.amazon.smithy.swift.codegen.model.hasTrait import software.amazon.smithy.swift.codegen.model.toMemberNames +import software.amazon.smithy.swift.codegen.swiftmodules.FoundationTypes import software.amazon.smithy.swift.codegen.swiftmodules.SmithyStreamsTypes import software.amazon.smithy.swift.codegen.swiftmodules.SmithyTimestampsTypes import software.amazon.smithy.swift.codegen.swiftmodules.SmithyTypes @@ -160,11 +161,12 @@ class ShapeValueGenerator( } ShapeType.BLOB -> { if (shape.hasTrait()) { - writer.writeInline(".stream(\$N(data: ", SmithyStreamsTypes.Core.BufferedStream) - ".data(using: .utf8)!, isClosed: true))" + writer.writeInline(".stream(\$N(data: \$N(", SmithyStreamsTypes.Core.BufferedStream, FoundationTypes.Data) + ".utf8), isClosed: true))" } else { // TODO: properly handle this optional with an unwrapped statement before it's passed as a value to a shape. - ".data(using: .utf8)!" + writer.writeInline("\$N(", FoundationTypes.Data) + ".utf8)" } } else -> { "" } diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/SwiftSymbolProvider.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/SwiftSymbolProvider.kt index a1234bd82..4942e639b 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/SwiftSymbolProvider.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/SwiftSymbolProvider.kt @@ -380,14 +380,14 @@ class SwiftSymbolProvider(private val model: Model, val swiftSettings: SwiftSett if (shape.hasTrait()) { { writer -> writer.format( - "\$N.data(\$N(\"$literal\".utf8))", + "\$N.data(\$N(base64Encoded: \"$literal\"))", SmithyTypes.ByteStream, FoundationTypes.Data ) } } else { { writer -> - writer.format("\$N(\"$literal\".utf8)", FoundationTypes.Data) + writer.format("\$N(base64Encoded: \"$literal\")", FoundationTypes.Data) } } ) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/member/MemberShapeDecodeGenerator.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/member/MemberShapeDecodeGenerator.kt index 510c1cd6b..e0bbde818 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/member/MemberShapeDecodeGenerator.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/serde/member/MemberShapeDecodeGenerator.kt @@ -243,14 +243,16 @@ open class MemberShapeDecodeGenerator( writer.addImport(FoundationTypes.Data) return if (targetShape.hasTrait()) { writer.format( - " ?? \$N.data(\$N(\"$value\".utf8))", + " ?? \$N.data(\$N(base64Encoded: \$S))", SmithyTypes.ByteStream, - FoundationTypes.Data + FoundationTypes.Data, + value, ) } else { writer.format( - " ?? \$N(\"$value\".utf8)", - FoundationTypes.Data + " ?? \$N(base64Encoded: \$S)", + FoundationTypes.Data, + value, ) } }