|
25 | 25 | import io.reshapr.proxy.registry.ServiceEntry; |
26 | 26 |
|
27 | 27 | import com.fasterxml.jackson.core.JsonProcessingException; |
| 28 | +import com.fasterxml.jackson.core.type.TypeReference; |
28 | 29 | import com.fasterxml.jackson.databind.JsonNode; |
29 | 30 | import com.fasterxml.jackson.databind.ObjectMapper; |
30 | 31 | import com.fasterxml.jackson.databind.node.ArrayNode; |
@@ -149,10 +150,19 @@ public Response getCallResponse(OperationEntry operation, ConfigurationEntry con |
149 | 150 | String paramIn = parameter.path("in").asText(); |
150 | 151 |
|
151 | 152 | if (request.arguments().containsKey(paramName)) { |
152 | | - String paramValue = request.arguments().remove(paramName).toString(); |
| 153 | + Object param = request.arguments().remove(paramName); |
| 154 | + String paramValue = param.toString(); |
153 | 155 | if ("path".equals(paramIn)) { |
154 | 156 | pathParams.put(paramName, paramValue); |
155 | 157 | } else if ("query".equals(paramIn)) { |
| 158 | + |
| 159 | + String paramType = parameter.path("schema").path(JSON_SCHEMA_TYPE_ELEMENT).asText(); |
| 160 | + // If parameter is an array, we expect a JSON array in input. |
| 161 | + if (JSON_SCHEMA_ARRAY_TYPE.equals(paramType)) { |
| 162 | + // We need to convert it to comma separated values for the backend call. |
| 163 | + List<String> values = mapper.convertValue(param, new TypeReference<List<String>>() {}); |
| 164 | + paramValue = String.join(",", values); |
| 165 | + } |
156 | 166 | queryParams.put(paramName, paramValue); |
157 | 167 | } else if ("header".equals(paramIn)) { |
158 | 168 | headers.put(paramName, List.of(paramValue)); |
@@ -299,6 +309,11 @@ private ObjectNode getInputSchemaNode(OperationEntry operation) { |
299 | 309 | if (paramSchema.has("enum")) { |
300 | 310 | propertyNode.set("enum", paramSchema.get("enum")); |
301 | 311 | } |
| 312 | + // |
| 313 | + if (JSON_SCHEMA_ARRAY_TYPE.equals(paramType) && paramSchema.has(JSON_SCHEMA_ITEMS_ELEMENT)) { |
| 314 | + propertyNode.set(JSON_SCHEMA_ITEMS_ELEMENT, |
| 315 | + dereferencedNode(schemaNode, paramSchema.get(JSON_SCHEMA_ITEMS_ELEMENT), new HashSet<>())); |
| 316 | + } |
302 | 317 | } |
303 | 318 | } |
304 | 319 | } |
|
0 commit comments