Skip to content

Commit

Permalink
Process StringArray parameter in ClientContextParams
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Aug 27, 2024
1 parent b04921e commit dee40fc
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import software.amazon.smithy.model.shapes.OperationShape;
import software.amazon.smithy.model.shapes.ServiceShape;
import software.amazon.smithy.model.shapes.Shape;
import software.amazon.smithy.model.shapes.ShapeType;
import software.amazon.smithy.rulesengine.traits.ClientContextParamsTrait;
import software.amazon.smithy.rulesengine.traits.ContextParamTrait;
import software.amazon.smithy.rulesengine.traits.EndpointRuleSetTrait;
Expand Down Expand Up @@ -68,10 +69,22 @@ public Map<String, String> getClientContextParams() {
if (trait.isPresent()) {
ClientContextParamsTrait clientContextParamsTrait = trait.get();
clientContextParamsTrait.getParameters().forEach((name, definition) -> {
map.put(
name,
definition.getType().toString().toLowerCase() // "boolean" and "string" are directly usable in TS.
);
ShapeType shapeType = definition.getType();
if (shapeType.isShapeType(ShapeType.STRING) || shapeType.isShapeType(ShapeType.BOOLEAN)) {
map.put(
name,
definition.getType().toString().toLowerCase() // "boolean" and "string" are directly usable in TS.
);
} else if (shapeType.isShapeType(ShapeType.LIST)) {
map.put(
name,
"string[]" // Only string lists are supported.
);
} else {
throw new RuntimeException("unexpected type "
+ definition.getType().toString()
+ " received as clientContextParam.");
}
});
}
return map;
Expand Down

0 comments on commit dee40fc

Please sign in to comment.