From 5181e05169d02486ea21d3775a0046051f86dfb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Madrigal=20=F0=9F=90=A7?= <599908+Madrigal@users.noreply.github.com> Date: Thu, 31 Oct 2024 10:52:18 -0400 Subject: [PATCH] Update string shape from synthetic to base --- .../smithy/go/codegen/util/ShapeUtil.java | 2 +- .../GoJmespathExpressionGeneratorTest.java | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/util/ShapeUtil.java b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/util/ShapeUtil.java index 718b564f..3461776f 100644 --- a/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/util/ShapeUtil.java +++ b/codegen/smithy-go-codegen/src/main/java/software/amazon/smithy/go/codegen/util/ShapeUtil.java @@ -27,7 +27,7 @@ public final class ShapeUtil { public static final StringShape STRING_SHAPE = StringShape.builder() - .id("smithy.go.synthetic#String") + .id("smithy.api#String") .build(); public static final IntegerShape INT_SHAPE = IntegerShape.builder() diff --git a/codegen/smithy-go-codegen/src/test/java/software/amazon/smithy/go/codegen/GoJmespathExpressionGeneratorTest.java b/codegen/smithy-go-codegen/src/test/java/software/amazon/smithy/go/codegen/GoJmespathExpressionGeneratorTest.java index aed60877..ad4ed55b 100644 --- a/codegen/smithy-go-codegen/src/test/java/software/amazon/smithy/go/codegen/GoJmespathExpressionGeneratorTest.java +++ b/codegen/smithy-go-codegen/src/test/java/software/amazon/smithy/go/codegen/GoJmespathExpressionGeneratorTest.java @@ -492,4 +492,33 @@ public void testMultiSelect() { v3 := []*string{v1,v2} """)); } + + @Test + public void testMultiSelectFlatten() { + var expr = "objectList[*].[key][]"; + + var writer = testWriter(); + var generator = new GoJmespathExpressionGenerator(testContext(), writer); + var actual = generator.generate(JmespathExpression.parse(expr), new GoJmespathExpressionGenerator.Variable( + TEST_MODEL.expectShape(ShapeId.from("smithy.go.test#Struct")), + "input" + )); + assertThat(actual.shape().toShapeId().toString(), Matchers.equalTo("smithy.go.synthetic#StringList")); + assertThat(actual.ident(), Matchers.equalTo("v5")); + assertThat(writer.toString(), Matchers.containsString(""" + v1 := input.ObjectList + var v2 [][]string + for _, v := range v1 { + v3 := v.Key + v4 := []*string{v3} + if v4 != nil { + v2 = append(v2, *v4) + } + } + var v5 []string + for _, v := range v2 { + v5 = append(v5, v...) + } + """)); + } }