From dee40fcc21757dcd0305d457e173c4cfcc13448c Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Tue, 27 Aug 2024 20:57:58 +0000 Subject: [PATCH] Process StringArray parameter in ClientContextParams --- .../endpointsV2/RuleSetParameterFinder.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) 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 1850952aa04..99678b75658 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 @@ -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; @@ -68,10 +69,22 @@ public Map 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;