From 2ab214def0bf2d572e6938279f3e5a5584fdd69e Mon Sep 17 00:00:00 2001 From: George Fu Date: Fri, 27 Sep 2024 17:07:21 +0000 Subject: [PATCH] correct location of union deser import --- .../codegen/integration/HttpBindingProtocolGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java index 3341f9d7ab4..a1a2e9e7cb1 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpBindingProtocolGenerator.java @@ -2469,7 +2469,6 @@ private HttpBinding readPayload( + "= __expectObject(await parseBody(output.body, context));"); } else if (target instanceof UnionShape) { // If payload is a Union, then we need to parse the string into JavaScript object. - importUnionDeserializer(writer); writer.write("const data: Record | undefined " + "= await parseBody(output.body, context);"); } else if (target instanceof StringShape || target instanceof DocumentShape) { @@ -2485,6 +2484,7 @@ private HttpBinding readPayload( "if (Object.keys(data ?? {}).length) {", "}", () -> { + importUnionDeserializer(writer); writer.write("contents.$L = __expectUnion($L);", binding.getMemberName(), getOutputValue(context, Location.PAYLOAD, "data", binding.getMember(), target)); }