diff --git a/codegen-client-test/model/error-correction-nullability-test.smithy b/codegen-client-test/model/error-correction-nullability-test.smithy index 8a125d3004..67bfef5464 100644 --- a/codegen-client-test/model/error-correction-nullability-test.smithy +++ b/codegen-client-test/model/error-correction-nullability-test.smithy @@ -102,7 +102,7 @@ apply SayHello @httpResponseTests([{ listValue: [], mapValue: {}, doubleListValue: [] - document: null + document: {} nested: { a: "" } }, code: 200, diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt index c9997ba67a..2ca52895d6 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/generators/http/HttpBindingGenerator.kt @@ -617,17 +617,26 @@ class HttpBindingGenerator( )(this) } - rustBlock("for ${loopVariable.name} in ${context.valueExpression.asRef()}") { - this.renderHeaderValue( - headerName, - loopVariable, - model.expectShape(shape.member.target), - isMultiValuedHeader = true, - timestampFormat, - renderErrorMessage, - serializeIfDefault = true, - shape.member, - ) + rustTemplate( + """ + // Empty vec in header is serialized as the empty string + if ${context.valueExpression.name}.is_empty() { + builder = builder.header("$headerName", ""); + }""", + ) + rustBlock("else") { + rustBlock("for ${loopVariable.name} in ${context.valueExpression.asRef()}") { + this.renderHeaderValue( + headerName, + loopVariable, + model.expectShape(shape.member.target), + isMultiValuedHeader = true, + timestampFormat, + renderErrorMessage, + serializeIfDefault = true, + shape.member, + ) + } } } @@ -671,14 +680,12 @@ class HttpBindingGenerator( val safeName = safeName("formatted") rustTemplate( """ - let $safeName = $formatted; - if !$safeName.is_empty() { - let header_value = $safeName; - let header_value: #{HeaderValue} = header_value.parse().map_err(|err| { - #{invalid_field_error:W} - })?; - builder = builder.header("$headerName", header_value); - } + let header_value = $formatted; + let header_value: #{HeaderValue} = header_value.parse().map_err(|err| { + #{invalid_field_error:W} + })?; + builder = builder.header("$headerName", header_value); + """, "HeaderValue" to RuntimeType.Http.resolve("HeaderValue"), "invalid_field_error" to renderErrorMessage("header_value"), diff --git a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/RpcV2Cbor.kt b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/RpcV2Cbor.kt index d3d9800b1a..2832333f59 100644 --- a/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/RpcV2Cbor.kt +++ b/codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/smithy/protocols/RpcV2Cbor.kt @@ -112,7 +112,7 @@ open class RpcV2Cbor(val codegenContext: CodegenContext) : Protocol { override val defaultTimestampFormat: TimestampFormatTrait.Format = TimestampFormatTrait.Format.EPOCH_SECONDS override fun additionalRequestHeaders(operationShape: OperationShape): List> = - listOf("smithy-protocol" to "rpc-v2-cbor") + listOf("smithy-protocol" to "rpc-v2-cbor", "accept" to "application/cbor") override fun additionalResponseHeaders(operationShape: OperationShape): List> = listOf("smithy-protocol" to "rpc-v2-cbor") diff --git a/gradle.properties b/gradle.properties index b5e1d59057..38f4db3df4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,7 +15,7 @@ smithy.rs.runtime.crate.unstable.version=0.60.6 kotlin.code.style=official # codegen smithyGradlePluginVersion=0.9.0 -smithyVersion=1.51.0 +smithyVersion=1.52.0 allowLocalDeps=false # kotlin kotlinVersion=1.9.20