diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/SymbolVisitor.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/SymbolVisitor.java index 723d7e89cf8..0a478152036 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/SymbolVisitor.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/SymbolVisitor.java @@ -67,6 +67,7 @@ import software.amazon.smithy.model.traits.EnumTrait; import software.amazon.smithy.model.traits.MediaTypeTrait; import software.amazon.smithy.model.traits.StreamingTrait; +import software.amazon.smithy.model.traits.UnitTypeTrait; import software.amazon.smithy.utils.SmithyInternalApi; import software.amazon.smithy.utils.StringUtils; @@ -458,13 +459,20 @@ public String formatModuleName(Shape shape, String name) { return visitedModels.get(shape); } // Add models into buckets no bigger than chunk size. - String path = String.join("/", ".", SHAPE_NAMESPACE_PREFIX, "models_" + bucketCount); - visitedModels.put(shape, path); - currentBucketSize++; - if (currentBucketSize == chunkSize) { - bucketCount++; - currentBucketSize = 0; + String path; + if (shape.getId().equals(UnitTypeTrait.UNIT)) { + // Unit should only be put in the zero bucket, since it does not + // generate anything. It also does not contribute to bucket size. + path = String.join("/", ".", SHAPE_NAMESPACE_PREFIX, "models_0"); + } else { + path = String.join("/", ".", SHAPE_NAMESPACE_PREFIX, "models_" + bucketCount); + currentBucketSize++; + if (currentBucketSize == chunkSize) { + bucketCount++; + currentBucketSize = 0; + } } + visitedModels.put(shape, path); return path; }