Skip to content

Commit e11f749

Browse files
authored
fix(codegen): omit unnamed enums in runtime object test (#1791)
1 parent 7ffe200 commit e11f749

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/PackageApiValidationGenerator.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import software.amazon.smithy.model.knowledge.TopDownIndex;
1616
import software.amazon.smithy.model.shapes.OperationShape;
1717
import software.amazon.smithy.model.shapes.Shape;
18+
import software.amazon.smithy.model.traits.EnumTrait;
1819
import software.amazon.smithy.typescript.codegen.knowledge.ServiceClosure;
1920
import software.amazon.smithy.utils.SmithyInternalApi;
2021

@@ -146,7 +147,16 @@ public void writeRuntimeIndexTest() {
146147
}
147148

148149
// enums
149-
TreeSet<Shape> enumShapes = serviceClosure.getEnums();
150+
151+
// string shapes with enum trait do not generate anything if
152+
// any enum value does not have a name.
153+
TreeSet<Shape> enumShapes = serviceClosure.getEnums().stream()
154+
.filter(shape -> shape
155+
.getTrait(EnumTrait.class)
156+
.map(EnumTrait::hasNames)
157+
.orElse(true))
158+
.collect(TreeSet::new, Set::add, Set::addAll);
159+
150160
if (!enumShapes.isEmpty()) {
151161
writer.write("// enums");
152162
}

0 commit comments

Comments
 (0)