Skip to content

Commit 3333049

Browse files
committed
Base64-decode default blob values
1 parent 1333c24 commit 3333049

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

codegen/smithy-aws-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/aws/protocols/core/AwsHttpBindingProtocolGenerator.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ abstract class AwsHttpBindingProtocolGenerator : HttpBindingProtocolGenerator()
4141

4242
val ignoredTests = TestMemberDelta(
4343
setOf(
44-
"AwsJson10ClientErrorCorrectsWithDefaultValuesWhenServerFailsToSerializeRequiredValues", // FIXME Protocol test seems to be wrong. Default value of the member is "YmxvYg==" but they are expecting it to be decoded "blob".
45-
"RpcV2CborClientPopulatesDefaultsValuesWhenMissingInResponse", // FIXME Protocol test seems to be wrong. Default value of member is "YWJj" but they are expecting it to be decoded "abc".
4644
"RpcV2CborClientPopulatesDefaultValuesInInput", // FIXME Bug in protocol test, malformed Base64 body. Fix will be in the next Smithy release: https://github.com/smithy-lang/smithy/pull/2502
4745
),
4846
)

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/core/KotlinSymbolProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class KotlinSymbolProvider(private val model: Model, private val settings: Kotli
241241
.takeUnless { it.isEmpty() }
242242
?.let { "ByteStream.fromString(${it.dq()})" }
243243

244-
targetShape.isBlobShape -> "${node.toString().dq()}.encodeToByteArray()"
244+
targetShape.isBlobShape -> "${node.toString().dq()}.decodeBase64().encodeToByteArray()"
245245

246246
targetShape.isDocumentShape -> getDefaultValueForDocument(node)
247247
targetShape.isTimestampShape -> getDefaultValueForTimestamp(node.asNumberNode().get())

codegen/smithy-kotlin-codegen/src/main/kotlin/software/amazon/smithy/kotlin/codegen/rendering/StructureGenerator.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ class StructureGenerator(
248248
} else {
249249
memberSymbol
250250
}
251+
252+
if (builderMemberSymbol.shape is BlobShape && builderMemberSymbol.isNotNullable) {
253+
writer.addImport(RuntimeTypes.Core.Text.Encoding.decodeBase64)
254+
}
255+
251256
write("public var #L: #E", memberName, builderMemberSymbol)
252257
}
253258
write("")

0 commit comments

Comments
 (0)