26
26
import software .amazon .smithy .codegen .core .SymbolProvider ;
27
27
import software .amazon .smithy .codegen .core .SymbolReference ;
28
28
import software .amazon .smithy .model .Model ;
29
- import software .amazon .smithy .model .knowledge .OperationIndex ;
30
29
import software .amazon .smithy .model .knowledge .TopDownIndex ;
31
30
import software .amazon .smithy .model .shapes .OperationShape ;
32
31
import software .amazon .smithy .model .shapes .ServiceShape ;
33
- import software .amazon .smithy .model .shapes .StructureShape ;
34
32
import software .amazon .smithy .typescript .codegen .integration .RuntimeClientPlugin ;
35
33
import software .amazon .smithy .typescript .codegen .integration .TypeScriptIntegration ;
36
34
import software .amazon .smithy .utils .OptionalUtils ;
@@ -90,18 +88,19 @@ static String getResolvedConfigTypeName(Symbol symbol) {
90
88
91
89
@ Override
92
90
public void run () {
93
- OperationIndex operationIndex = model .getKnowledge (OperationIndex .class );
94
91
writer .addImport ("Client" , "__Client" , "@aws-sdk/smithy-client" );
95
92
writer .addImport ("ClientDefaultValues" , "__ClientDefaultValues" , "./runtimeConfig" );
96
93
97
94
// Normalize the input and output types of the command to account for
98
95
// things like an operation adding input where there once wasn't any
99
96
// 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 -> {
101
99
// Use an empty object if an operation doesn't define input.
102
100
writer .write ("| {}" );
103
101
});
104
- writeInputOutputTypeUnion ("ServiceOutputTypes" , writer , operationIndex ::getOutput , writer -> {
102
+ writeInputOutputTypeUnion ("ServiceOutputTypes" , writer ,
103
+ operationSymbol -> operationSymbol .getProperty ("outputType" , Symbol .class ), writer -> {
105
104
// Use a MetadataBearer if an operation doesn't define output.
106
105
writer .addImport ("MetadataBearer" , "__MetadataBearer" , TypeScriptDependency .AWS_SDK_TYPES .packageName );
107
106
writer .write ("| __MetadataBearer" );
@@ -115,14 +114,15 @@ public void run() {
115
114
private void writeInputOutputTypeUnion (
116
115
String typeName ,
117
116
TypeScriptWriter writer ,
118
- Function <OperationShape , Optional <StructureShape >> mapper ,
117
+ Function <Symbol , Optional <Symbol >> mapper ,
119
118
Consumer <TypeScriptWriter > defaultTypeGenerator
120
119
) {
121
120
TopDownIndex topDownIndex = model .getKnowledge (TopDownIndex .class );
122
121
Set <OperationShape > containedOperations = topDownIndex .getContainedOperations (service );
122
+
123
123
List <Symbol > symbols = containedOperations .stream ()
124
- .flatMap (operation -> OptionalUtils .stream (mapper .apply (operation )))
125
124
.map (symbolProvider ::toSymbol )
125
+ .flatMap (operation -> OptionalUtils .stream (mapper .apply (operation )))
126
126
.sorted (Comparator .comparing (Symbol ::getName ))
127
127
.collect (Collectors .toList ());
128
128
0 commit comments