Skip to content

Commit ee8c78d

Browse files
committed
fix broken protocol tests
1 parent 47568dd commit ee8c78d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ 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",
44+
// Test broken in Smithy 1.50.0, should be fixed by https://github.com/smithy-lang/smithy/pull/2341
45+
"RestJsonClientIgnoresDefaultValuesIfMemberValuesArePresentInResponse",
4646
),
4747
)
4848

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

Lines changed: 8 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,14 @@ class KotlinSymbolProvider(private val model: Model, private val settings: Kotli
235235
"${enumSymbol.fullName}.fromValue($arg)"
236236
}
237237

238+
targetShape.isBlobShape && targetShape.isStreaming ->
239+
node
240+
.toString()
241+
.takeUnless { it.isEmpty() }
242+
?.let { "ByteStream.fromString(${it.dq()})" }
243+
238244
targetShape.isBlobShape -> "${node.toString().dq()}.encodeToByteArray()"
245+
239246
targetShape.isDocumentShape -> getDefaultValueForDocument(node)
240247
targetShape.isTimestampShape -> getDefaultValueForTimestamp(node.asNumberNode().get())
241248

0 commit comments

Comments
 (0)