diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java index 76820c25a3c..d242ff7e52b 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/CommandGenerator.java @@ -20,6 +20,7 @@ import static software.amazon.smithy.typescript.codegen.CodegenUtils.writeClientCommandStreamingOutputType; import java.nio.file.Paths; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; @@ -191,18 +192,8 @@ private void generateEndpointParameterInstructionProvider() { "return {", "};", () -> { RuleSetParameterFinder parameterFinder = new RuleSetParameterFinder(service); - parameterFinder.getBuiltInParams().forEach((name, type) -> { - writer.write( - "$L: { type: \"builtInParams\", name: \"$L\" },", - name, EndpointsParamNameMap.getLocalName(name) - ); - }); - parameterFinder.getClientContextParams().forEach((name, type) -> { - writer.write( - "$L: { type: \"clientContextParams\", name: \"$L\" },", - name, EndpointsParamNameMap.getLocalName(name) - ); - }); + Set paramNames = new HashSet<>(); + Shape operationInput = model.getShape(operation.getInputShape()).get(); parameterFinder.getStaticContextParamValues(operationInput).forEach((name, value) -> { writer.write( @@ -216,6 +207,24 @@ private void generateEndpointParameterInstructionProvider() { name, EndpointsParamNameMap.getLocalName(name) ); }); + parameterFinder.getClientContextParams().forEach((name, type) -> { + if (!paramNames.contains(name)) { + writer.write( + "$L: { type: \"clientContextParams\", name: \"$L\" },", + name, EndpointsParamNameMap.getLocalName(name) + ); + } + paramNames.add(name); + }); + parameterFinder.getBuiltInParams().forEach((name, type) -> { + if (!paramNames.contains(name)) { + writer.write( + "$L: { type: \"builtInParams\", name: \"$L\" },", + name, EndpointsParamNameMap.getLocalName(name) + ); + } + paramNames.add(name); + }); } ); } diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/endpointsV2/EndpointsParamNameMap.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/endpointsV2/EndpointsParamNameMap.java index c3d2bd7d46a..fe413f4249c 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/endpointsV2/EndpointsParamNameMap.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/endpointsV2/EndpointsParamNameMap.java @@ -38,6 +38,21 @@ public static void addNameMapping(Map parameterNameMap) { } public static String getLocalName(String endpointsV2ParamName) { - return MAPPING.getOrDefault(endpointsV2ParamName, endpointsV2ParamName); + boolean isTitleCase = false; + if (endpointsV2ParamName.length() >= 2) { + String char1 = endpointsV2ParamName.substring(0, 1); + String char2 = endpointsV2ParamName.substring(1, 2); + if (char1.toUpperCase().equals(char1) && char2.toLowerCase().equals(char2)) { + isTitleCase = true; + } + } + + String suggestedName = endpointsV2ParamName; + if (isTitleCase) { + suggestedName = endpointsV2ParamName.substring(0, 1).toLowerCase() + + endpointsV2ParamName.substring(1); + } + + return MAPPING.getOrDefault(endpointsV2ParamName, suggestedName); } }