Skip to content

Commit da46fdd

Browse files
committed
use command input/output shape for public typing instead of shapes in protocol
1 parent baf03e6 commit da46fdd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@
2626
import software.amazon.smithy.codegen.core.SymbolProvider;
2727
import software.amazon.smithy.codegen.core.SymbolReference;
2828
import software.amazon.smithy.model.Model;
29-
import software.amazon.smithy.model.knowledge.OperationIndex;
3029
import software.amazon.smithy.model.knowledge.TopDownIndex;
3130
import software.amazon.smithy.model.shapes.OperationShape;
3231
import software.amazon.smithy.model.shapes.ServiceShape;
33-
import software.amazon.smithy.model.shapes.StructureShape;
3432
import software.amazon.smithy.typescript.codegen.integration.RuntimeClientPlugin;
3533
import software.amazon.smithy.typescript.codegen.integration.TypeScriptIntegration;
3634
import software.amazon.smithy.utils.OptionalUtils;
@@ -90,18 +88,19 @@ static String getResolvedConfigTypeName(Symbol symbol) {
9088

9189
@Override
9290
public void run() {
93-
OperationIndex operationIndex = model.getKnowledge(OperationIndex.class);
9491
writer.addImport("Client", "__Client", "@aws-sdk/smithy-client");
9592
writer.addImport("ClientDefaultValues", "__ClientDefaultValues", "./runtimeConfig");
9693

9794
// Normalize the input and output types of the command to account for
9895
// things like an operation adding input where there once wasn't any
9996
// input, adding output, naming differences between services, etc.
100-
writeInputOutputTypeUnion("ServiceInputTypes", writer, operationIndex::getInput, writer -> {
97+
writeInputOutputTypeUnion("ServiceInputTypes", writer,
98+
operationSymbol -> operationSymbol.getProperty("inputType", Symbol.class), writer -> {
10199
// Use an empty object if an operation doesn't define input.
102100
writer.write("| {}");
103101
});
104-
writeInputOutputTypeUnion("ServiceOutputTypes", writer, operationIndex::getOutput, writer -> {
102+
writeInputOutputTypeUnion("ServiceOutputTypes", writer,
103+
operationSymbol -> operationSymbol.getProperty("outputType", Symbol.class), writer -> {
105104
// Use a MetadataBearer if an operation doesn't define output.
106105
writer.addImport("MetadataBearer", "__MetadataBearer", TypeScriptDependency.AWS_SDK_TYPES.packageName);
107106
writer.write("| __MetadataBearer");
@@ -115,14 +114,15 @@ public void run() {
115114
private void writeInputOutputTypeUnion(
116115
String typeName,
117116
TypeScriptWriter writer,
118-
Function<OperationShape, Optional<StructureShape>> mapper,
117+
Function<Symbol, Optional<Symbol>> mapper,
119118
Consumer<TypeScriptWriter> defaultTypeGenerator
120119
) {
121120
TopDownIndex topDownIndex = model.getKnowledge(TopDownIndex.class);
122121
Set<OperationShape> containedOperations = topDownIndex.getContainedOperations(service);
122+
123123
List<Symbol> symbols = containedOperations.stream()
124-
.flatMap(operation -> OptionalUtils.stream(mapper.apply(operation)))
125124
.map(symbolProvider::toSymbol)
125+
.flatMap(operation -> OptionalUtils.stream(mapper.apply(operation)))
126126
.sorted(Comparator.comparing(Symbol::getName))
127127
.collect(Collectors.toList());
128128

0 commit comments

Comments
 (0)