diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/endpointsV2/RuleSetParameterFinder.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/endpointsV2/RuleSetParameterFinder.java index 09816b72756..db0a35dbcff 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/endpointsV2/RuleSetParameterFinder.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/endpointsV2/RuleSetParameterFinder.java @@ -84,26 +84,39 @@ public List getEffectiveParams() { Queue ruleQueue = new ArrayDeque<>(endpointRuleSet.getRules()); Queue conditionQueue = new ArrayDeque<>(); - Queue argQueue = new ArrayDeque<>(); + Queue argQueue = new ArrayDeque<>(); while (!ruleQueue.isEmpty() || !conditionQueue.isEmpty() || !argQueue.isEmpty()) { while (!argQueue.isEmpty()) { - ObjectNode arg = argQueue.poll(); - Optional ref = arg.getMember("ref"); - if (ref.isPresent()) { - String refName = ref.get().expectStringNode().getValue(); - if (initialParams.contains(refName)) { - effectiveParams.add(refName); + Node arg = argQueue.poll(); + if (arg.isObjectNode()) { + Optional ref = arg.expectObjectNode().getMember("ref"); + if (ref.isPresent()) { + String refName = ref.get().expectStringNode().getValue(); + if (initialParams.contains(refName)) { + effectiveParams.add(refName); + } } - } - Optional argv = arg.getMember("argv"); - if (argv.isPresent()) { - ArrayNode nestedArgv = argv.get().expectArrayNode(); - for (Node nestedArg : nestedArgv) { - if (nestedArg.isObjectNode()) { - argQueue.add(nestedArg.expectObjectNode()); + Optional argv = arg.expectObjectNode().getMember("argv"); + if (argv.isPresent()) { + ArrayNode nestedArgv = argv.get().expectArrayNode(); + for (Node nestedArg : nestedArgv) { + if (nestedArg.isObjectNode()) { + argQueue.add(nestedArg.expectObjectNode()); + } } } + } else if (arg.isStringNode()) { + String argString = arg.expectStringNode().getValue(); + URL_PARAMETERS + .matcher(argString) + .results().forEach(matchResult -> { + if (matchResult.groupCount() >= 1) { + if (initialParams.contains(matchResult.group(1))) { + effectiveParams.add(matchResult.group(1)); + } + } + }); } } @@ -113,9 +126,7 @@ public List getEffectiveParams() { .expectObjectNode() .expectArrayMember("argv"); for (Node arg : argv) { - if (arg.isObjectNode()) { - argQueue.add(arg.expectObjectNode()); - } + argQueue.add(arg); } } diff --git a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/endpointsV2/RuleSetParameterFinderTest.java b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/endpointsV2/RuleSetParameterFinderTest.java index 9a7c4529080..12a59ac6b85 100644 --- a/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/endpointsV2/RuleSetParameterFinderTest.java +++ b/smithy-typescript-codegen/src/test/java/software/amazon/smithy/typescript/codegen/endpointsV2/RuleSetParameterFinderTest.java @@ -40,6 +40,11 @@ class RuleSetParameterFinderTest { "required": false, "documentation": "...", "type": "String" + }, + "ShorthandParameter": { + "required": true, + "documentation": "...", + "type": "String" } }, "rules": [ @@ -83,6 +88,13 @@ class RuleSetParameterFinderTest { }, true ] + }, + { + "fn": "stringEquals", + "argv": [ + "literal", + "{ShorthandParameter}" + ] } ], "endpoint": { @@ -109,6 +121,6 @@ void getEffectiveParams(@Mock ServiceShape serviceShape, @Mock EndpointRuleSetTr List effectiveParams = subject.getEffectiveParams(); - assertEquals(List.of("BasicParameter", "NestedParameter", "UrlOnlyParameter"), effectiveParams); + assertEquals(List.of("BasicParameter", "NestedParameter", "ShorthandParameter", "UrlOnlyParameter"), effectiveParams); } } \ No newline at end of file