Skip to content

Commit 8191c6a

Browse files
authored
fix(types): expand custom endpoint type (#622)
1 parent c7e19b9 commit 8191c6a

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/endpointsV2/ParameterGenerator.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,15 @@ public String toCodeString(boolean isClientContextParam) {
109109
buffer += "?";
110110
}
111111
buffer += ": ";
112-
if (isClientContextParam) {
113-
buffer += (tsParamType + "|" + "Provider<" + tsParamType + ">") + ";";
112+
113+
if (parameterName.equals("endpoint")) {
114+
buffer += "string | Provider<string> | Endpoint | Provider<Endpoint> | EndpointV2 | Provider<EndpointV2>;";
114115
} else {
115-
buffer += tsParamType + ";";
116+
if (isClientContextParam) {
117+
buffer += (tsParamType + "|" + "Provider<" + tsParamType + ">") + ";";
118+
} else {
119+
buffer += tsParamType + ";";
120+
}
116121
}
117122
return buffer;
118123
}

smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/endpointsV2/RuleSetParametersVisitor.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ public Void objectNode(ObjectNode node) {
6464

6565
ParameterGenerator parameterGenerator = new ParameterGenerator(localKey, param);
6666

67+
if (localKey.equals("endpoint")) {
68+
writer.addImport("Endpoint", null, "@aws-sdk/types");
69+
writer.addImport("EndpointV2", null, "@aws-sdk/types");
70+
writer.addImport("Provider", null, "@aws-sdk/types");
71+
}
72+
6773
if (writeDefaults) {
6874
if (parameterGenerator.hasDefault()) {
6975
writer.write(parameterGenerator.defaultAsCodeString());

0 commit comments

Comments
 (0)