From 39c0096c33417d44f125a042c112b3c16918098a Mon Sep 17 00:00:00 2001 From: david-perez Date: Mon, 3 Oct 2022 18:19:56 +0200 Subject: [PATCH] Remove unnecessary call to upgrade to a server protocol for `ServerServiceGeneratorV2` (#1805) The protocol `ServerServiceGenerator` hosts is already typed as a `ServerProtocol`. --- .../codegen/server/smithy/generators/ServerServiceGenerator.kt | 3 +-- .../codegen/server/smithy/protocols/ServerRestJsonFactory.kt | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt index a9670d013b..ecb56283ac 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/generators/ServerServiceGenerator.kt @@ -89,10 +89,9 @@ open class ServerServiceGenerator( rustCrate.withModule( RustModule("service", RustMetadata(visibility = Visibility.PUBLIC, additionalAttributes = listOf(Attribute.DocHidden)), null), ) { writer -> - val serverProtocol = ServerProtocol.fromCoreProtocol(protocol) ServerServiceGeneratorV2( codegenContext, - serverProtocol, + protocol, ).render(writer) } diff --git a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestJsonFactory.kt b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestJsonFactory.kt index ee7e609ccc..d3d0fea631 100644 --- a/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestJsonFactory.kt +++ b/codegen-server/src/main/kotlin/software/amazon/smithy/rust/codegen/server/smithy/protocols/ServerRestJsonFactory.kt @@ -8,7 +8,6 @@ package software.amazon.smithy.rust.codegen.server.smithy.protocols import software.amazon.smithy.rust.codegen.core.smithy.generators.protocol.ProtocolSupport import software.amazon.smithy.rust.codegen.core.smithy.protocols.Protocol import software.amazon.smithy.rust.codegen.core.smithy.protocols.ProtocolGeneratorFactory -import software.amazon.smithy.rust.codegen.core.smithy.protocols.RestJson import software.amazon.smithy.rust.codegen.server.smithy.ServerCodegenContext import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.ServerRestJsonProtocol @@ -17,7 +16,7 @@ import software.amazon.smithy.rust.codegen.server.smithy.generators.protocol.Ser * with RestJson1 specific configurations. */ class ServerRestJsonFactory : ProtocolGeneratorFactory { - override fun protocol(codegenContext: ServerCodegenContext): Protocol = RestJson(codegenContext) + override fun protocol(codegenContext: ServerCodegenContext): Protocol = ServerRestJsonProtocol(codegenContext) override fun buildProtocolGenerator(codegenContext: ServerCodegenContext): ServerHttpBoundProtocolGenerator = ServerHttpBoundProtocolGenerator(codegenContext, ServerRestJsonProtocol(codegenContext))