From 8a2ea839dc366a4e36c3a4bdf0dcd09c79dec1a2 Mon Sep 17 00:00:00 2001 From: George Fu Date: Mon, 9 Dec 2024 17:45:16 +0000 Subject: [PATCH] uniform usage of LazyJsonString --- .../codegen/integration/HttpProtocolGeneratorUtils.java | 4 ++-- .../codegen/integration/DocumentMemberDeserVisitorTest.java | 2 +- .../codegen/integration/DocumentMemberSerVisitorTest.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpProtocolGeneratorUtils.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpProtocolGeneratorUtils.java index 849cc03d80f..fa74c2ece7f 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpProtocolGeneratorUtils.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/integration/HttpProtocolGeneratorUtils.java @@ -176,7 +176,7 @@ public static String getStringInputParam(GenerationContext context, Shape shape, if (CodegenUtils.isJsonMediaType(mediaType)) { TypeScriptWriter writer = context.getWriter(); writer.addImport("LazyJsonString", "__LazyJsonString", TypeScriptDependency.AWS_SMITHY_CLIENT); - return "__LazyJsonString.fromObject(" + dataSource + ")"; + return "__LazyJsonString.from(" + dataSource + ")"; } else { LOGGER.warning(() -> "Found unsupported mediatype " + mediaType + " on String shape: " + shape); } @@ -210,7 +210,7 @@ public static String getStringOutputParam(GenerationContext context, if (CodegenUtils.isJsonMediaType(mediaType)) { TypeScriptWriter writer = context.getWriter(); writer.addImport("LazyJsonString", "__LazyJsonString", TypeScriptDependency.AWS_SMITHY_CLIENT); - return "new __LazyJsonString(" + dataSource + ")"; + return "__LazyJsonString.from(" + dataSource + ")"; } else { LOGGER.warning(() -> "Found unsupported mediatype " + mediaType + " on String shape: " + shape); } diff --git a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/integration/DocumentMemberDeserVisitorTest.java b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/integration/DocumentMemberDeserVisitorTest.java index 9d306538565..80b762db823 100644 --- a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/integration/DocumentMemberDeserVisitorTest.java +++ b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/integration/DocumentMemberDeserVisitorTest.java @@ -98,7 +98,7 @@ public static Collection validMemberTargetTypes() { {StringShape.builder().id(id).build(), "__expectString(" + DATA_SOURCE + ")", source}, { StringShape.builder().id(id).addTrait(new MediaTypeTrait("foo+json")).build(), - "new __LazyJsonString(" + DATA_SOURCE + ")", + "__LazyJsonString.from(" + DATA_SOURCE + ")", source }, {BlobShape.builder().id(id).build(), "context.base64Decoder(" + DATA_SOURCE + ")", source}, diff --git a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/integration/DocumentMemberSerVisitorTest.java b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/integration/DocumentMemberSerVisitorTest.java index fcee0c535f6..f82420f3f95 100644 --- a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/integration/DocumentMemberSerVisitorTest.java +++ b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/integration/DocumentMemberSerVisitorTest.java @@ -83,7 +83,7 @@ public static Collection validMemberTargetTypes() { {StringShape.builder().id(id).build(), DATA_SOURCE}, { StringShape.builder().id(id).addTrait(new MediaTypeTrait("foo+json")).build(), - "__LazyJsonString.fromObject(" + DATA_SOURCE + ")" + "__LazyJsonString.from(" + DATA_SOURCE + ")" }, {BlobShape.builder().id(id).build(), "context.base64Encoder(" + DATA_SOURCE + ")"}, {DocumentShape.builder().id(id).build(), delegate},