Skip to content
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

chore: Update to Smithy 1.53.0 #866

Merged
merged 3 commits into from
Dec 19, 2024
Merged

chore: Update to Smithy 1.53.0 #866

merged 3 commits into from
Dec 19, 2024

Conversation

jbelkins
Copy link
Contributor

@jbelkins jbelkins commented Nov 21, 2024

Description of changes

Updates to Smithy 1.53.0.

Fixes a couple code-generated default values to decode Base64 blob defaults before using them.

Scope

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@@ -380,14 +380,14 @@ class SwiftSymbolProvider(private val model: Model, val swiftSettings: SwiftSett
if (shape.hasTrait<StreamingTrait>()) {
{ writer ->
writer.format(
"\$N.data(\$N(\"$literal\".utf8))",
"\$N.data(\$N(base64Encoded: \"$literal\"))",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Smithy blob default values are always base64-encoded strings so the default is decoded here.

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))"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A little code cleanup & converted to using Swift string's utf8 view to create data.

@@ -243,14 +243,16 @@ open class MemberShapeDecodeGenerator(
writer.addImport(FoundationTypes.Data)
return if (targetShape.hasTrait<StreamingTrait>()) {
writer.format(
" ?? \$N.data(\$N(\"$value\".utf8))",
" ?? \$N.data(\$N(base64Encoded: \$S))",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same fixes here: decode the blob default string from base64 before using.

@jbelkins jbelkins marked this pull request as ready for review December 19, 2024 16:35
@jbelkins jbelkins merged commit b4ba0ad into main Dec 19, 2024
27 checks passed
@jbelkins jbelkins deleted the jbe/smithy_1_53_0 branch December 19, 2024 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants