Skip to content

Commit eee6fe6

Browse files
authored
user interface for command input output instead of type (#313)
This will eliminate extra type alias link that users need to click through when inspecting the operation input/output shape in the API reference
1 parent 34faa48 commit eee6fe6

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,13 @@ private void writeInputType(String typeName, Optional<StructureShape> inputShape
192192
StructureShape input = inputShape.get();
193193
List<MemberShape> blobStreamingMembers = getBlobStreamingMembers(input);
194194
if (blobStreamingMembers.isEmpty()) {
195-
writer.write("export type $L = $T;", typeName, symbolProvider.toSymbol(input));
195+
writer.write("export interface $L extends $T {}", typeName, symbolProvider.toSymbol(input));
196196
} else {
197197
writeStreamingInputType(typeName, input, blobStreamingMembers.get(0));
198198
}
199199
} else {
200200
// If the input is non-existent, then use an empty object.
201-
writer.write("export type $L = {}", typeName);
201+
writer.write("export interface $L {}", typeName);
202202
}
203203
}
204204

@@ -207,10 +207,10 @@ private void writeOutputType(String typeName, Optional<StructureShape> outputSha
207207
// to a defined output shape.
208208
writer.addImport("MetadataBearer", "__MetadataBearer", TypeScriptDependency.AWS_SDK_TYPES.packageName);
209209
if (outputShape.isPresent()) {
210-
writer.write("export type $L = $T & __MetadataBearer;",
210+
writer.write("export interface $L extends $T, __MetadataBearer {}",
211211
typeName, symbolProvider.toSymbol(outputShape.get()));
212212
} else {
213-
writer.write("export type $L = __MetadataBearer", typeName);
213+
writer.write("export interface $L extends __MetadataBearer {}", typeName);
214214
}
215215
}
216216

@@ -235,8 +235,14 @@ private void writeStreamingInputType(String typeName, StructureShape inputShape,
235235
Symbol inputSymbol = symbolProvider.toSymbol(inputShape);
236236
String memberName = streamingMember.getMemberName();
237237
String optionalSuffix = streamingMember.isRequired() ? "" : "?";
238-
writer.openBlock("export type $L = Omit<$T, $S> & {", "};", typeName, inputSymbol, memberName, () ->
239-
writer.write("$1L$2L: $3T[$1S]|string|Uint8Array|Buffer;", memberName, optionalSuffix, inputSymbol));
238+
writer.openBlock("type $LType = Omit<$T, $S> & {", "};", typeName, inputSymbol, memberName, () -> {
239+
writer.writeDocs(String.format("For *`%1$s[\"%2$s\"]`*, see {@link %1$s.%2$s}.",
240+
inputSymbol.getName(), memberName));
241+
writer.write("$1L$2L: $3T[$1S]|string|Uint8Array|Buffer;", memberName, optionalSuffix, inputSymbol);
242+
});
243+
writer.writeDocs(String.format("This interface extends from `%1$s` interface. There are more parameters than"
244+
+ " `%2$s` defined in {@link %1$s}", inputSymbol.getName(), memberName));
245+
writer.write("export interface $1L extends $1LType {}", typeName);
240246
}
241247

242248
private void addCommandSpecificPlugins() {

0 commit comments

Comments
 (0)