Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow lowercase endpoint param #923

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -58,6 +68,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 @@ -112,7 +126,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