[
https://issues.apache.org/jira/browse/SCB-928?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16649263#comment-16649263
]
ASF GitHub Bot commented on SCB-928:
------------------------------------
yhs0092 commented on a change in pull request #952: [SCB-928] support
"collection-format" feature on query param
URL:
https://github.com/apache/incubator-servicecomb-java-chassis/pull/952#discussion_r224979917
##########
File path:
swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/converter/property/SwaggerParamCollectionFormat.java
##########
@@ -57,6 +68,41 @@ public String getSeparator() {
if (null == rawParam) {
return new String[0];
}
- return rawParam.split(separator);
+ return rawParam.split(separator, -1);
+ }
+
+ /**
+ * Join params with {@link #separator}.
+ * Null element will be ignored since {@code null} cannot be described in
query array param.
+ *
+ * @return joined params, or return {@code null} if {@code params} is null
or all elements of {@code params} are null.
+ */
+ public String joinParam(Collection<?> params) {
+ if (null == params) {
Review comment:
I've test `org.apache.commons.lang3.StringUtils#join(java.lang.Iterable<?>,
char)`, but there is a problem.
Since `StringUtils#join` will treat null element as blank string `""`, it
may cause some query param problem. If user pass a query array containing null
element like `new String[]{"a",null,"b"}`, provider will get `new
String[]{"a","","b"}` instead of `new String[]{"a","b"}`.
If we add some extra logic to filter null element, the performance will be
not so good as this implementation.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> support swagger "collection-format" feature
> -------------------------------------------
>
> Key: SCB-928
> URL: https://issues.apache.org/jira/browse/SCB-928
> Project: Apache ServiceComb
> Issue Type: Task
> Components: Java-Chassis
> Reporter: wujimin
> Assignee: YaoHaishi
> Priority: Major
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)