diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java index f8d0756090e..b541f1d70f4 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java @@ -531,8 +531,12 @@ static void writeIndex( TopDownIndex topDownIndex = TopDownIndex.of(model); Set containedOperations = new TreeSet<>(topDownIndex.getContainedOperations(service)); - for (OperationShape operation : containedOperations) { - writer.write("export * from \"./$L\";", symbolProvider.toSymbol(operation).getName()); + if (containedOperations.isEmpty()) { + writer.write("export {};"); + } else { + for (OperationShape operation : containedOperations) { + writer.write("export * from \"./$L\";", symbolProvider.toSymbol(operation).getName()); + } } fileManifest.writeFile( diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/DirectedTypeScriptCodegen.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/DirectedTypeScriptCodegen.java index 945108f3325..0c9b5851cba 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/DirectedTypeScriptCodegen.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/DirectedTypeScriptCodegen.java @@ -300,18 +300,24 @@ private void generateCommands(GenerateServiceDirective new CommandGenerator( settings, model, operation, symbolProvider, commandWriter, runtimePlugins, protocolGenerator, applicationProtocol).run()); } if (settings.generateServerSdk()) { - ServerCommandGenerator.writeIndex(model, service, symbolProvider, fileManifest); delegator.useShapeWriter(operation, commandWriter -> new ServerCommandGenerator( settings, model, operation, symbolProvider, commandWriter, protocolGenerator, applicationProtocol).run()); diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServerCommandGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServerCommandGenerator.java index 31c794875cc..644b0748d78 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServerCommandGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServerCommandGenerator.java @@ -240,8 +240,12 @@ static void writeIndex( TopDownIndex topDownIndex = TopDownIndex.of(model); Set containedOperations = new TreeSet<>(topDownIndex.getContainedOperations(service)); - for (OperationShape operation : containedOperations) { - writer.write("export * from \"./$L\";", symbolProvider.toSymbol(operation).getName()); + if (containedOperations.isEmpty()) { + writer.write("export {};"); + } else { + for (OperationShape operation : containedOperations) { + writer.write("export * from \"./$L\";", symbolProvider.toSymbol(operation).getName()); + } } fileManifest.writeFile( diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceBareBonesClientGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceBareBonesClientGenerator.java index 7c3f09177d9..1f35f2e4494 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceBareBonesClientGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/ServiceBareBonesClientGenerator.java @@ -142,7 +142,7 @@ private void writeInputOutputTypeUnion( writer.write("export type $L = ", typeName); writer.indent(); // If we have less symbols than operations, at least one doesn't have a type, so add the default. - if (containedOperations.size() != symbols.size()) { + if (containedOperations.size() != symbols.size() || containedOperations.isEmpty()) { defaultTypeGenerator.accept(writer); } for (int i = 0; i < symbols.size(); i++) {