Skip to content

Commit d998422

Browse files
authored
chore(codegen): add _json fn import to call site (#5837)
1 parent 7b4487d commit d998422

File tree

1 file changed

+7
-5
lines changed
  • codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/visitor

1 file changed

+7
-5
lines changed

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/visitor/MemberDeserVisitor.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public class MemberDeserVisitor implements ShapeVisitor<String> {
5353
protected GenerationContext context;
5454
protected String dataSource;
5555
protected TimestampFormatTrait.Format defaultTimestampFormat;
56+
protected boolean disableDeserializationFunctionElision;
5657

5758
public MemberDeserVisitor(
5859
GenerationContext context,
@@ -63,6 +64,11 @@ public MemberDeserVisitor(
6364
this.defaultTimestampFormat = defaultTimestampFormat;
6465
this.serdeElisionIndex = SerdeElisionIndex.of(context.getModel());
6566
this.context = context;
67+
disableDeserializationFunctionElision = DeserializerElisionDenyList.SDK_IDS.contains(
68+
context.getService().getTrait(ServiceTrait.class)
69+
.map(ServiceTrait::getSdkId)
70+
.orElse(null)
71+
);
6672
}
6773

6874
@Override
@@ -251,15 +257,11 @@ protected String getDelegateDeserializer(Shape shape) {
251257
protected String getDelegateDeserializer(Shape shape, String customDataSource) {
252258
// Use the shape for the function name.
253259
Symbol symbol = context.getSymbolProvider().toSymbol(shape);
254-
boolean disableDeserializationFunctionElision = DeserializerElisionDenyList.SDK_IDS.contains(
255-
context.getService().getTrait(ServiceTrait.class)
256-
.map(ServiceTrait::getSdkId)
257-
.orElse(null)
258-
);
259260

260261
if (serdeElisionEnabled
261262
&& !disableDeserializationFunctionElision
262263
&& serdeElisionIndex.mayElide(shape)) {
264+
context.getWriter().addImport("_json", null, TypeScriptDependency.AWS_SMITHY_CLIENT);
263265
return "_json(" + customDataSource + ")";
264266
}
265267

0 commit comments

Comments
 (0)