Skip to content

Commit

Permalink
Fix rendering of constrained lists as header values
Browse files Browse the repository at this point in the history
  • Loading branch information
jjant committed Nov 29, 2022
1 parent a0e561e commit f759439
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,14 @@ class HttpBindingGenerator(
renderErrorMessage: (String) -> Writable,
) {
val loopVariable = ValueExpression.Reference(safeName("inner"))
rustBlock("for ${loopVariable.name} in ${value.asRef()}") {
val context = HeaderValueSerializationContext(value, shape)
for (customization in customizations) {
customization.section(
HttpBindingSection.BeforeRenderingHeaderValue(context),
)(this)
}

rustBlock("for ${loopVariable.name} in ${context.valueExpression.asRef()}") {
this.renderHeaderValue(
headerName,
loopVariable,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
package software.amazon.smithy.rust.codegen.server.smithy.generators.http

import software.amazon.smithy.codegen.core.Symbol
import software.amazon.smithy.model.shapes.CollectionShape
import software.amazon.smithy.model.shapes.OperationShape
import software.amazon.smithy.model.shapes.Shape
import software.amazon.smithy.model.shapes.StructureShape
Expand Down Expand Up @@ -90,7 +91,7 @@ class ServerResponseBeforeRenderingHeadersHttpBindingCustomization(val codegenCo
codegenContext.settings.codegenConfig.publicConstrainedTypes,
)
) {
if (section.context.shape.isIntegerShape) {
if (section.context.shape.isIntegerShape || section.context.shape is CollectionShape) {
section.context.valueExpression =
ValueExpression.Reference("&${section.context.valueExpression.name.removePrefix("&")}.0")
}
Expand Down

0 comments on commit f759439

Please sign in to comment.