Skip to content

Commit

Permalink
fix: allow lowercase endpoint param (#923)
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhe authored Sep 8, 2023
1 parent b44467a commit 8e23b1b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,21 @@ public class ParameterGenerator {
private final String parameterName;
private final Node param;
private boolean required = false;
private boolean isInputKey;
private String tsParamType = "string";

public ParameterGenerator(String key, Node param) {
/**
* @param key - the param name.
* @param param - the param value.
* @param isInputKey - whether the key is a client input key. This is
* distinct from canonical endpoint param name
* because it has been transformed to match
* pre-existing keys in published clients.
*/
public ParameterGenerator(String key, Node param, boolean isInputKey) {
parameterName = key;
this.param = param;
this.isInputKey = isInputKey;

ObjectNode paramNode = param.asObjectNode()
.orElseThrow(() -> new RuntimeException("param node is not object node."));
Expand All @@ -60,6 +70,10 @@ public ParameterGenerator(String key, Node param) {
}
}

public ParameterGenerator(String key, Node param) {
this(key, param, false);
}

public boolean isBuiltIn() {
return param.expectObjectNode().containsMember("builtIn");
}
Expand Down Expand Up @@ -114,7 +128,7 @@ public String toCodeString(boolean isClientContextParam) {
}
buffer += ": ";

if (parameterName.equals("endpoint")) {
if (parameterName.equals("endpoint") && isInputKey) {
buffer += "string | Provider<string> | Endpoint | Provider<Endpoint> | EndpointV2 | Provider<EndpointV2>;";
} else {
if (isClientContextParam) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public Void objectNode(ObjectNode node) {
localKey = EndpointsParamNameMap.getLocalName(key);
}

ParameterGenerator parameterGenerator = new ParameterGenerator(localKey, param);
ParameterGenerator parameterGenerator = new ParameterGenerator(localKey, param, useLocalNames);

if (localKey.equals("endpoint")) {
writer.addImport("Endpoint", null, TypeScriptDependency.SMITHY_TYPES);
Expand Down

0 comments on commit 8e23b1b

Please sign in to comment.