Skip to content

Commit c6466c5

Browse files
committed
fix(codegen): omit unnamed enums in runtime object test
1 parent 716bf8e commit c6466c5

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

@@ -134,7 +135,16 @@ public void writeRuntimeIndexTest() {
134135
}
135136

136137
// enums
137-
TreeSet<Shape> enumShapes = serviceClosure.getEnums();
138+
139+
// string shapes with enum trait do not generate anything if
140+
// any enum value does not have a name.
141+
TreeSet<Shape> enumShapes = serviceClosure.getEnums().stream()
142+
.filter(shape -> shape
143+
.getTrait(EnumTrait.class)
144+
.map(EnumTrait::hasNames)
145+
.orElse(true))
146+
.collect(TreeSet::new, Set::add, Set::addAll);
147+
138148
if (!enumShapes.isEmpty()) {
139149
writer.write("// enums");
140150
}

0 commit comments

Comments
 (0)