Skip to content

Commit

Permalink
do NOT serialize empty lists in ec2query (#2630)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucix-aws authored May 10, 2024
1 parent 0457ec5 commit 0ac88f6
Show file tree
Hide file tree
Showing 17 changed files with 828 additions and 31 deletions.
8 changes: 8 additions & 0 deletions .changelog/2781886a806d48bda53e5be2992aa455.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "2781886a-806d-48bd-a53e-5be2992aa455",
"type": "bugfix",
"description": "Fix serialization behavior of empty lists.",
"modules": [
"service/ec2"
]
}
2 changes: 1 addition & 1 deletion codegen/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
smithyVersion=1.47.0
smithyVersion=1.49.0
smithyGradleVersion=0.7.0
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
import java.util.Optional;
import java.util.function.Predicate;
import software.amazon.smithy.aws.traits.protocols.Ec2QueryNameTrait;
import software.amazon.smithy.go.codegen.GoWriter;
import software.amazon.smithy.go.codegen.integration.ProtocolGenerator.GenerationContext;
import software.amazon.smithy.go.codegen.knowledge.GoPointableIndex;
import software.amazon.smithy.model.shapes.CollectionShape;
import software.amazon.smithy.model.shapes.MemberShape;
import software.amazon.smithy.model.shapes.Shape;
import software.amazon.smithy.model.shapes.ShapeType;
import software.amazon.smithy.model.traits.TimestampFormatTrait.Format;
import software.amazon.smithy.model.traits.XmlNameTrait;
Expand Down Expand Up @@ -51,6 +55,14 @@ protected String getSerializedLocationName(MemberShape memberShape, String defau
.orElse(defaultValue));
}

// EC2Query specifically does not serialize non-nil, empty lists
protected void serializeCollection(GenerationContext context, CollectionShape shape) {
context.getWriter().get()
.write("if len(v) == 0 { return nil }");

super.serializeCollection(context, shape);
}

@Override
protected boolean isFlattened(GenerationContext context, MemberShape memberShape) {
// All lists, sets, and maps are flattened in aws.ec2.
Expand Down
4 changes: 2 additions & 2 deletions internal/protocoltest/ec2query/api_op_QueryLists_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions internal/protocoltest/ec2query/serializers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0ac88f6

Please sign in to comment.