File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -210,6 +210,37 @@ private void generateClientCommand() {
210210 .protocolGenerator (protocolGenerator )
211211 .applicationProtocol (applicationProtocol )
212212 .build ());
213+
214+ {
215+ // This block places the most commonly sought type definitions
216+ // closer to the command definition, for navigation assistance
217+ // in IDEs.
218+ Shape operationInputShape = model .expectShape (operation .getInputShape ());
219+ Symbol baseInput = symbolProvider .toSymbol (operationInputShape );
220+ Shape operationOutputShape = model .expectShape (operation .getOutputShape ());
221+ Symbol baseOutput = symbolProvider .toSymbol (operationOutputShape );
222+
223+ writer .write ("/** @internal type navigation helper, not in runtime. */" );
224+ writer .openBlock ("declare protected static __types: {" , "};" , () -> {
225+ String baseInputStr = operationInputShape .getAllMembers ().isEmpty ()
226+ ? "{}"
227+ : baseInput .getName ();
228+ String baseOutputStr = operationOutputShape .getAllMembers ().isEmpty ()
229+ ? "{}"
230+ : baseOutput .getName ();
231+ writer .write ("""
232+ api: {
233+ input: $L;
234+ output: $L;
235+ };""" , baseInputStr , baseOutputStr );
236+ writer .write ("""
237+ sdk: {
238+ input: $T;
239+ output: $T;
240+ };""" , inputType , outputType );
241+ });
242+ }
243+
213244 writer .write ("}" ); // class close bracket.
214245 }
215246
You can’t perform that action at this time.
0 commit comments