From f5eb55b967b1af46f372482301c0926150986e2b Mon Sep 17 00:00:00 2001 From: Ed Paulosky Date: Wed, 16 Nov 2022 12:52:28 -0500 Subject: [PATCH] Noops when encoding an empty body in xml --- .../middlewares/handlers/HttpBodyMiddleware.kt | 8 +------- .../src/test/kotlin/HttpBodyMiddlewareTests.kt | 5 ----- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/middlewares/handlers/HttpBodyMiddleware.kt b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/middlewares/handlers/HttpBodyMiddleware.kt index 76e1b467f..cf7cd56c6 100644 --- a/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/middlewares/handlers/HttpBodyMiddleware.kt +++ b/smithy-swift-codegen/src/main/kotlin/software/amazon/smithy/swift/codegen/integration/middlewares/handlers/HttpBodyMiddleware.kt @@ -111,17 +111,11 @@ class HttpBodyMiddleware( renderEncodedBodyAddedToRequest(bodyDeclaration, dataDeclaration) } writer.indent() - writer.openBlock("if encoder is JSONEncoder {", "} else if encoder is XMLEncoder {") { + writer.openBlock("if encoder is JSONEncoder {", "}") { writer.write("// Encode an empty body as an empty structure in JSON") writer.write("let \$L = \"{}\".data(using: .utf8)!", dataDeclaration) renderEncodedBodyAddedToRequest(bodyDeclaration, dataDeclaration) } - writer.indent() - writer.write("// Encode an empty body as an empty string in XML") - writer.write("let \$L = \"\".data(using: .utf8)!", dataDeclaration) - renderEncodedBodyAddedToRequest(bodyDeclaration, dataDeclaration) - writer.dedent() - writer.write("}") writer.dedent() writer.write("}") } diff --git a/smithy-swift-codegen/src/test/kotlin/HttpBodyMiddlewareTests.kt b/smithy-swift-codegen/src/test/kotlin/HttpBodyMiddlewareTests.kt index 1ed3db63c..0f00c5b67 100644 --- a/smithy-swift-codegen/src/test/kotlin/HttpBodyMiddlewareTests.kt +++ b/smithy-swift-codegen/src/test/kotlin/HttpBodyMiddlewareTests.kt @@ -160,11 +160,6 @@ class HttpBodyMiddlewareTests { let payload1data = "{}".data(using: .utf8)! let payload1body = ClientRuntime.HttpBody.data(payload1data) input.builder.withBody(payload1body) - } else if encoder is XMLEncoder { - // Encode an empty body as an empty string in XML - let payload1data = "".data(using: .utf8)! - let payload1body = ClientRuntime.HttpBody.data(payload1data) - input.builder.withBody(payload1body) } } } catch let err {