Skip to content

Commit

Permalink
chore(codegen): add _json fn import to call site (#5837)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe authored Feb 28, 2024
1 parent 7b4487d commit d998422
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class MemberDeserVisitor implements ShapeVisitor<String> {
protected GenerationContext context;
protected String dataSource;
protected TimestampFormatTrait.Format defaultTimestampFormat;
protected boolean disableDeserializationFunctionElision;

public MemberDeserVisitor(
GenerationContext context,
Expand All @@ -63,6 +64,11 @@ public MemberDeserVisitor(
this.defaultTimestampFormat = defaultTimestampFormat;
this.serdeElisionIndex = SerdeElisionIndex.of(context.getModel());
this.context = context;
disableDeserializationFunctionElision = DeserializerElisionDenyList.SDK_IDS.contains(
context.getService().getTrait(ServiceTrait.class)
.map(ServiceTrait::getSdkId)
.orElse(null)
);
}

@Override
Expand Down Expand Up @@ -251,15 +257,11 @@ protected String getDelegateDeserializer(Shape shape) {
protected String getDelegateDeserializer(Shape shape, String customDataSource) {
// Use the shape for the function name.
Symbol symbol = context.getSymbolProvider().toSymbol(shape);
boolean disableDeserializationFunctionElision = DeserializerElisionDenyList.SDK_IDS.contains(
context.getService().getTrait(ServiceTrait.class)
.map(ServiceTrait::getSdkId)
.orElse(null)
);

if (serdeElisionEnabled
&& !disableDeserializationFunctionElision
&& serdeElisionIndex.mayElide(shape)) {
context.getWriter().addImport("_json", null, TypeScriptDependency.AWS_SMITHY_CLIENT);
return "_json(" + customDataSource + ")";
}

Expand Down

0 comments on commit d998422

Please sign in to comment.