Skip to content

Commit 8ba8a52

Browse files
AllanZhengYPsrchase
authored andcommitted
generate interface for client input and resolved config (smithy-lang#312)
* generate interface for client input and resolved config This improves usability of API reference because all available parameters are now shown on same page
1 parent 2963b5f commit 8ba8a52

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ private void generateConfig() {
150150

151151
// The default configuration type is always just the base-level
152152
// Smithy configuration requirements.
153-
writer.write("export type $L = Partial<__SmithyConfiguration<$T>>", configType,
153+
writer.write("type $LType = Partial<__SmithyConfiguration<$T>>", configType,
154154
applicationProtocol.getOptionsType());
155155
writer.write(" & ClientDefaults");
156156

@@ -169,10 +169,14 @@ private void generateConfig() {
169169
writer.dedent();
170170
}
171171

172+
writer.writeDocs(String.format("The configuration interface of %s class constructor that set the region, "
173+
+ "credentials and other options.", symbol.getName()));
174+
writer.write("export interface $1L extends $1LType {}", configType);
175+
172176
// Generate the corresponding "Resolved" configuration type to account for
173177
// each "Input" configuration type.
174178
writer.write("");
175-
writer.write("export type $L = __SmithyResolvedConfiguration<$T>",
179+
writer.write("type $LType = __SmithyResolvedConfiguration<$T>",
176180
resolvedConfigType, applicationProtocol.getOptionsType());
177181
writer.write(" & Required<ClientDefaults>");
178182

@@ -184,6 +188,11 @@ private void generateConfig() {
184188
writer.dedent();
185189
}
186190

191+
writer.writeDocs(String.format("The resolved configuration interface of %s class. This is resolved and"
192+
+ " normalized from the {@link %s | constructor configuration interface}.", symbol.getName(),
193+
configType));
194+
writer.write("export interface $1L extends $1LType {}", resolvedConfigType);
195+
187196
writer.popState();
188197
}
189198

@@ -268,6 +277,8 @@ private void generateService() {
268277
private void generateClientProperties() {
269278
// Hook for adding/changing client properties.
270279
writer.pushState(CLIENT_PROPERTIES_SECTION);
280+
writer.writeDocs(String.format("The resolved configuration of %s class. This is resolved and normalized from "
281+
+ "the {@link %s | constructor configuration interface}.", symbol.getName(), configType));
271282
writer.write("readonly config: $L;\n", resolvedConfigType);
272283
writer.popState();
273284
}

0 commit comments

Comments
 (0)