From d4c23e3fd2b62acb966083397e2ebf0bb8391250 Mon Sep 17 00:00:00 2001 From: david-perez Date: Fri, 25 Feb 2022 12:27:38 +0100 Subject: [PATCH] Bugfix: render server HTTP response code bindings again (#1207) In 171d76f, we regressed on HTTP response code binding in (non-error) operation outputs. We made the call to obtain the `Writable`, but we never wrote it with our writer. In that commit, I inadvertently added the `RestJsonHttpResponseCode` test (which was previoulsy passing) to the list of failing tests without noticing the regression. --- .../smithy/generators/protocol/ServerProtocolTestGenerator.kt | 1 - .../server/smithy/protocols/ServerHttpProtocolGenerator.kt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt index 6448a3f6b..98a02ef6c 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/protocol/ServerProtocolTestGenerator.kt @@ -650,7 +650,6 @@ class ServerProtocolTestGenerator( FailingTest(RestJson, "RestJsonFooErrorWithDunderType", TestType.Response), FailingTest(RestJson, "RestJsonFooErrorWithDunderTypeAndNamespace", TestType.Response), FailingTest(RestJson, "RestJsonFooErrorWithDunderTypeUriAndNamespace", TestType.Response), - FailingTest(RestJson, "RestJsonHttpResponseCode", TestType.Response), FailingTest(RestJson, "RestJsonNoInputAndNoOutput", TestType.Response), FailingTest(RestJson, "RestJsonStreamingTraitsRequireLengthWithBlob", TestType.Response), FailingTest(RestJson, "RestJsonHttpWithEmptyBlobPayload", TestType.Request), diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpProtocolGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpProtocolGenerator.kt index f41c64fc2..89becf201 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpProtocolGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerHttpProtocolGenerator.kt @@ -465,7 +465,7 @@ private class ServerHttpProtocolImplGenerator( Attribute.AllowUnusedMut.render(this) rustTemplate("let mut builder = #{http}::Response::builder();", *codegenScope) serverRenderResponseHeaders(operationShape) - bindings.find { it.location == HttpLocation.RESPONSE_CODE }?.let { serverRenderResponseCodeBinding(it) } + bindings.find { it.location == HttpLocation.RESPONSE_CODE }?.let { serverRenderResponseCodeBinding(it)(this) } operationShape.outputShape(model).findStreamingMember(model)?.let { val memberName = symbolProvider.toMemberName(it) -- GitLab