Skip to content

Commit 09a642a

Browse files
authored
Fix set serialization via loops (#975)
1 parent b824833 commit 09a642a

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ public void serializeCollection(GenerationContext context, CollectionShape shape
5656
TypeScriptWriter writer = context.getWriter();
5757
Shape target = context.getModel().expectShape(shape.getMember().getTarget());
5858

59-
// Dispatch to the input value provider for any additional handling.
60-
writer.openBlock("return (input || []).map(entry =>", ");", () -> {
61-
writer.write(target.accept(getMemberVisitor("entry")));
62-
});
59+
writer.write("const contents = [];");
60+
writer.openBlock("for (let entry of input) {", "}", () ->
61+
// Dispatch to the input value provider for any additional handling.
62+
writer.write("contents.push($L);", target.accept(getMemberVisitor("entry"))));
63+
writer.write("return contents;");
6364
}
6465

6566
@Override

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ protected void serializeCollection(GenerationContext context, CollectionShape sh
6464
writer.write("const entries: any = {};");
6565
// Set up a counter to increment the member entries.
6666
writer.write("let counter = 1;");
67-
// Dispatch to the input value provider for any additional handling.
68-
writer.openBlock("(input || []).map(entry => {", "});", () -> {
67+
writer.openBlock("for (let entry of input) {", "}", () -> {
68+
// Dispatch to the input value provider for any additional handling.
6969
serializeUnnamedMemberEntryList(context, target, "entry", locationName);
7070
writer.write("counter++;");
7171
});

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ protected void serializeCollection(GenerationContext context, CollectionShape sh
7070

7171
// Set up a location to store all of the child node(s).
7272
writer.write("const collectedNodes: any = [];");
73-
// Dispatch to the input value provider for any additional handling.
74-
writer.openBlock("(input || []).map(entry => {", "});", () -> {
73+
writer.openBlock("for (let entry of input) {", "}", () -> {
74+
// Dispatch to the input value provider for any additional handling.
7575
writer.write("const node = $L;", target.accept(getMemberVisitor("entry")));
7676
writer.write("collectedNodes.push(node.withName($S));", locationName);
7777
});

0 commit comments

Comments
 (0)