Skip to content

Commit 05693cb

Browse files
committed
Fix serialization of default blob values
1 parent ea91fcd commit 05693cb

File tree

2 files changed

+6
-3
lines changed

2 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-
// This test requires populating blob members with a default value of "", which the sdk doesn't do
45-
"AwsJson10ClientPopulatesDefaultValuesInInput",
4644
),
4745
)
4846

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class KotlinSymbolProvider(private val model: Model, private val settings: Kotli
222222
private fun DefaultTrait.getDefaultValue(targetShape: Shape): String? {
223223
val node = toNode()
224224
return when {
225-
node.toString() == "null" || targetShape is BlobShape && node.toString() == "" -> null
225+
node.toString() == "null" -> null
226226

227227
// Check if target is an enum before treating the default like a regular number/string
228228
targetShape.isEnum -> {
@@ -235,7 +235,12 @@ class KotlinSymbolProvider(private val model: Model, private val settings: Kotli
235235
"${enumSymbol.fullName}.fromValue($arg)"
236236
}
237237

238+
targetShape.isBlobShape && targetShape.isStreaming -> when(node.toString()) {
239+
"" -> null
240+
else -> "ByteStream.fromString(${node.toString().dq()})"
241+
}
238242
targetShape.isBlobShape -> "${node.toString().dq()}.encodeToByteArray()"
243+
239244
targetShape.isDocumentShape -> getDefaultValueForDocument(node)
240245
targetShape.isTimestampShape -> getDefaultValueForTimestamp(node.asNumberNode().get())
241246

0 commit comments

Comments
 (0)