[
https://issues.apache.org/jira/browse/SCB-928?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16649266#comment-16649266
]
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_r224979939
##########
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:
Here is my test code in `SwaggerParamCollectionFormat`:
[SwaggerParamCollectionFormat.java](https://github.com/yhs0092/ServiceComb-Java-Chassis/blob/query_arr_param_joinParam/swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/converter/property/SwaggerParamCollectionFormat.java)
There is four tested method, `joinParam` is the original implementation,
`joinParam2`,`joinParam3`,`joinParam4` is the implementation that take use of
`StringUtils#join`.
Performance test case is the `main` method in
[SwaggerParamCollectionFormatTest.java](https://github.com/yhs0092/ServiceComb-Java-Chassis/blob/query_arr_param_joinParam/swagger/swagger-generator/generator-core/src/test/java/org/apache/servicecomb/swagger/converter/property/SwaggerParamCollectionFormatTest.java).
The average result of these four method is respectively
712/777/1609/1211 (test data is {"a","b","c"}),
787/1528/1784/1489 (test data is {null, "a", null, "b", null, "", null,
null, "c", null})
we can find the original implementation is always the best, especially in
round2, in which case there are null elements in query array.
Therefore, I think we can keep this implementation since it's function meets
our need.
----------------------------------------------------------------
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)