Skip to content

Commit 549a580

Browse files
committed
Add a mapper if Object values need to be processed
1 parent b969772 commit 549a580

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ public Map<String, String> getOperationContextParamValues(OperationShape operati
169169

170170
// Split JMESPath expression string on separator and add JavaScript equivalent.
171171
for (String part : path.split("[" + separator + "]")) {
172+
if (value.endsWith(")")) {
173+
// The value is an object, which needs to run on map.
174+
value += ".map(obj => obj";
175+
}
176+
172177
// Process keys https://jmespath.org/specification.html#keys
173178
if (part.startsWith("keys(")) {
174179
// Get provided object for which keys are to be extracted.
@@ -196,7 +201,7 @@ public Map<String, String> getOperationContextParamValues(OperationShape operati
196201
}
197202

198203
// Close all open brackets.
199-
value += ")".repeat((int) value.chars().filter(ch -> ch == '(').count());
204+
value += ")".repeat((int) (value.chars().filter(ch -> ch == '(').count() - value.chars().filter(ch -> ch == ')').count()));
200205

201206
map.put(name, value);
202207
});

0 commit comments

Comments
 (0)