You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2017/12/25 02:01:00 UTC
[GitHub] mt-monster closed pull request #448: JAV-579 ??????????
mt-monster closed pull request #448: JAV-579 ??????????
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/448
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/common/common-rest/src/main/java/io/servicecomb/common/rest/codec/QueryProcessorFactory.java b/common/common-rest/src/main/java/io/servicecomb/common/rest/codec/QueryProcessorFactory.java
new file mode 100644
index 000000000..dca3ff6f5
--- /dev/null
+++ b/common/common-rest/src/main/java/io/servicecomb/common/rest/codec/QueryProcessorFactory.java
@@ -0,0 +1,99 @@
+package io.servicecomb.common.rest.codec;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import com.fasterxml.jackson.databind.JavaType;
+
+import io.servicecomb.common.rest.codec.param.AbstractParamProcessor;
+import io.servicecomb.common.rest.codec.param.ParamValueProcessor;
+
+public class QueryProcessorFactory {
+
+ public static final String PARAMTYPE = "query";
+
+ private static Map strategyMap = new HashMap<>();
+
+ public QueryProcessorFactory() {
+ }
+
+ public QueryProcessorFactory(String paramPath, JavaType targetType) {
+
+ strategyMap.put(QueryTypeEnum.multi.value(), new MultiQueryProcessor(paramPath, targetType));
+ strategyMap.put(QueryTypeEnum.csv.value(), new CsvQueryProcessor(paramPath, targetType));
+ }
+
+ private static QueryProcessorFactory factory = new QueryProcessorFactory();
+
+ public static QueryProcessorFactory getInstance() {
+ return factory;
+ }
+
+ public ParamValueProcessor creator(Integer type) {
+ return (ParamValueProcessor) strategyMap.get(type);
+ }
+
+ public static class MultiQueryProcessor extends AbstractParamProcessor {
+ public MultiQueryProcessor(String paramPath, JavaType targetType) {
+ super(paramPath, targetType);
+ }
+
+ @Override
+ public Object getValue(HttpServletRequest request) throws Exception {
+ Object value = null;
+ if (targetType.isContainerType()) {
+ value = request.getParameterValues(paramPath);
+ } else {
+ value = request.getParameter(paramPath);
+ }
+
+ return convertValue(value, targetType);
+ }
+
+ @Override
+ public void setValue(RestClientRequest clientRequest, Object arg) throws Exception {
+ // query???set
+ }
+
+ @Override
+ public String getProcessorType() {
+ return PARAMTYPE;
+ }
+ }
+
+ public static class CsvQueryProcessor extends AbstractParamProcessor {
+
+
+ public CsvQueryProcessor(String paramPath, JavaType targetType) {
+ super(paramPath, targetType);
+ }
+
+ @Override
+ public Object getValue(HttpServletRequest request) throws Exception {
+ Object value = null;
+ if (targetType.isContainerType()) {
+ String[] strs = request.getParameterValues(paramPath);
+ for (String str : strs) {
+ value = Arrays.asList(str.split(","));
+ }
+ } else {
+ value = request.getParameter(paramPath);
+ }
+
+ return convertValue(value, targetType);
+ }
+
+ @Override
+ public void setValue(RestClientRequest clientRequest, Object arg) throws Exception {
+
+ }
+
+ @Override
+ public String getProcessorType() {
+ return PARAMTYPE;
+ }
+ }
+}
diff --git a/common/common-rest/src/main/java/io/servicecomb/common/rest/codec/QueryTypeEnum.java b/common/common-rest/src/main/java/io/servicecomb/common/rest/codec/QueryTypeEnum.java
new file mode 100644
index 000000000..99fd3d958
--- /dev/null
+++ b/common/common-rest/src/main/java/io/servicecomb/common/rest/codec/QueryTypeEnum.java
@@ -0,0 +1,37 @@
+package io.servicecomb.common.rest.codec;
+
+public enum QueryTypeEnum {
+
+ multi(0, "multi"),
+ csv(1, "csv"),
+ ssv(2, "ssv"),
+ tsv(3, "tsv"),
+ pipes(4, "pipes");
+
+ private int value;
+
+ private String description;
+
+ QueryTypeEnum(int value, String description) {
+ this.value = value;
+ this.description = description;
+ }
+
+ public int value() {
+ return value;
+ }
+
+ public String description() {
+ return description;
+ }
+
+ public static QueryTypeEnum valueOf(int value) {
+ for (QueryTypeEnum typeEnum : QueryTypeEnum.values()) {
+ if (typeEnum.value == value) {
+ return typeEnum;
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/common/common-rest/src/main/java/io/servicecomb/common/rest/codec/param/QueryProcessorCreator.java b/common/common-rest/src/main/java/io/servicecomb/common/rest/codec/param/QueryProcessorCreator.java
index 60f0a70cc..19545407b 100644
--- a/common/common-rest/src/main/java/io/servicecomb/common/rest/codec/param/QueryProcessorCreator.java
+++ b/common/common-rest/src/main/java/io/servicecomb/common/rest/codec/param/QueryProcessorCreator.java
@@ -1,12 +1,11 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Copyright 2017 Huawei Technologies Co., Ltd
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -19,44 +18,17 @@
import java.lang.reflect.Type;
-import javax.servlet.http.HttpServletRequest;
-
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.type.TypeFactory;
-import io.servicecomb.common.rest.codec.RestClientRequest;
+import io.servicecomb.common.rest.codec.QueryProcessorFactory;
+import io.servicecomb.common.rest.codec.QueryTypeEnum;
import io.swagger.models.parameters.Parameter;
+import io.swagger.models.parameters.QueryParameter;
public class QueryProcessorCreator implements ParamValueProcessorCreator {
public static final String PARAMTYPE = "query";
- public static class QueryProcessor extends AbstractParamProcessor {
- public QueryProcessor(String paramPath, JavaType targetType) {
- super(paramPath, targetType);
- }
-
- @Override
- public Object getValue(HttpServletRequest request) throws Exception {
- Object value = null;
- if (targetType.isContainerType()) {
- value = request.getParameterValues(paramPath);
- } else {
- value = request.getParameter(paramPath);
- }
-
- return convertValue(value, targetType);
- }
-
- @Override
- public void setValue(RestClientRequest clientRequest, Object arg) throws Exception {
- // query???set
- }
-
- @Override
- public String getProcessorType() {
- return PARAMTYPE;
- }
- }
public QueryProcessorCreator() {
ParamValueProcessorCreatorManager.INSTANCE.register(PARAMTYPE, this);
@@ -65,6 +37,13 @@ public QueryProcessorCreator() {
@Override
public ParamValueProcessor create(Parameter parameter, Type genericParamType) {
JavaType targetType = TypeFactory.defaultInstance().constructType(genericParamType);
- return new QueryProcessor(parameter.getName(), targetType);
- }
-}
+
+ QueryProcessorFactory queryProcessorFactory = new QueryProcessorFactory(parameter.getName(), targetType);
+
+ String collectionFormat = ((QueryParameter) parameter).getCollectionFormat();
+ if (collectionFormat == null) {
+ return queryProcessorFactory.creator(QueryTypeEnum.multi.value());
+ }
+ return queryProcessorFactory.creator(QueryTypeEnum.valueOf(collectionFormat).value());
+ }
+}
\ No newline at end of file
diff --git a/common/common-rest/src/test/java/io/servicecomb/common/rest/codec/param/TestCsvQueryProcessor.java b/common/common-rest/src/test/java/io/servicecomb/common/rest/codec/param/TestCsvQueryProcessor.java
new file mode 100644
index 000000000..ad9e31a86
--- /dev/null
+++ b/common/common-rest/src/test/java/io/servicecomb/common/rest/codec/param/TestCsvQueryProcessor.java
@@ -0,0 +1,56 @@
+package io.servicecomb.common.rest.codec.param;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.hamcrest.Matchers;
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.fasterxml.jackson.databind.type.TypeFactory;
+
+import io.servicecomb.common.rest.codec.QueryProcessorFactory.CsvQueryProcessor;
+import mockit.Expectations;
+import mockit.Mocked;
+
+public class TestCsvQueryProcessor {
+ @Mocked
+ HttpServletRequest request;
+
+ private ParamValueProcessor createProcessor(String name, Class<?> type) {
+ return new CsvQueryProcessor(name, TypeFactory.defaultInstance().constructType(type));
+ }
+
+ @Test
+ public void testGetValueNormal() throws Exception {
+ new Expectations() {
+ {
+ request.getParameter("name");
+ result = "value";
+ }
+ };
+
+ ParamValueProcessor processor = createProcessor("name", String.class);
+ Object value = processor.getValue(request);
+ Assert.assertEquals("value", value);
+ }
+
+ @Test
+ public void testGetValueContainerType() throws Exception {
+ new Expectations() {
+ {
+ request.getParameterValues("name");
+ result = new String[] {"v1,v2,v3"};
+ }
+ };
+
+ ParamValueProcessor processor = createProcessor("name", String[].class);
+ String[] value = (String[]) processor.getValue(request);
+ Assert.assertThat(value, Matchers.arrayContaining("v1","v2","v3"));
+ }
+
+ @Test
+ public void testGetProcessorType() {
+ ParamValueProcessor processor = createProcessor("name", String.class);
+ Assert.assertEquals("query", processor.getProcessorType());
+ }
+}
diff --git a/common/common-rest/src/test/java/io/servicecomb/common/rest/codec/param/TestMultiQueryProcessor.java b/common/common-rest/src/test/java/io/servicecomb/common/rest/codec/param/TestMultiQueryProcessor.java
new file mode 100644
index 000000000..3692b1736
--- /dev/null
+++ b/common/common-rest/src/test/java/io/servicecomb/common/rest/codec/param/TestMultiQueryProcessor.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2017 Huawei Technologies Co., Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.servicecomb.common.rest.codec.param;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.hamcrest.Matchers;
+import org.junit.Assert;
+import org.junit.Test;
+
+import com.fasterxml.jackson.databind.type.TypeFactory;
+
+import io.servicecomb.common.rest.codec.QueryProcessorFactory.MultiQueryProcessor;
+import mockit.Expectations;
+import mockit.Mocked;
+
+public class TestMultiQueryProcessor {
+ @Mocked
+ HttpServletRequest request;
+
+ private ParamValueProcessor createProcessor(String name, Class<?> type) {
+ return new MultiQueryProcessor(name, TypeFactory.defaultInstance().constructType(type));
+ }
+
+ @Test
+ public void testGetValueNormal() throws Exception {
+ new Expectations() {
+ {
+ request.getParameter("name");
+ result = "value";
+ }
+ };
+
+ ParamValueProcessor processor = createProcessor("name", String.class);
+ Object value = processor.getValue(request);
+ Assert.assertEquals("value", value);
+ }
+
+ @Test
+ public void testGetValueContainerType() throws Exception {
+ new Expectations() {
+ {
+ request.getParameterValues("name");
+ result = new String[] {"v1,v2,v3"};
+ }
+ };
+
+ ParamValueProcessor processor = createProcessor("name", String[].class);
+ String[] value = (String[]) processor.getValue(request);
+ Assert.assertThat(value, Matchers.arrayContaining("v1,v2,v3"));
+ }
+
+ @Test
+ public void testGetProcessorType() {
+ ParamValueProcessor processor = createProcessor("name", String.class);
+ Assert.assertEquals("query", processor.getProcessorType());
+ }
+}
diff --git a/common/common-rest/src/test/java/io/servicecomb/common/rest/codec/param/TestQueryProcessor.java b/common/common-rest/src/test/java/io/servicecomb/common/rest/codec/param/TestQueryProcessor.java
index c775540be..9633bcc6e 100644
--- a/common/common-rest/src/test/java/io/servicecomb/common/rest/codec/param/TestQueryProcessor.java
+++ b/common/common-rest/src/test/java/io/servicecomb/common/rest/codec/param/TestQueryProcessor.java
@@ -25,7 +25,7 @@
import com.fasterxml.jackson.databind.type.TypeFactory;
-import io.servicecomb.common.rest.codec.param.QueryProcessorCreator.QueryProcessor;
+import io.servicecomb.common.rest.codec.QueryProcessorFactory.MultiQueryProcessor;
import mockit.Expectations;
import mockit.Mocked;
@@ -34,7 +34,7 @@
HttpServletRequest request;
private ParamValueProcessor createProcessor(String name, Class<?> type) {
- return new QueryProcessor(name, TypeFactory.defaultInstance().constructType(type));
+ return new MultiQueryProcessor(name, TypeFactory.defaultInstance().constructType(type));
}
@Test
diff --git a/common/common-rest/src/test/java/io/servicecomb/common/rest/codec/param/TestQueryProcessorCreator.java b/common/common-rest/src/test/java/io/servicecomb/common/rest/codec/param/TestQueryProcessorCreator.java
index 02f4f3c70..d82ed93b3 100644
--- a/common/common-rest/src/test/java/io/servicecomb/common/rest/codec/param/TestQueryProcessorCreator.java
+++ b/common/common-rest/src/test/java/io/servicecomb/common/rest/codec/param/TestQueryProcessorCreator.java
@@ -1,12 +1,11 @@
/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
+ * Copyright 2017 Huawei Technologies Co., Ltd
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -20,9 +19,13 @@
import org.junit.Assert;
import org.junit.Test;
-import io.servicecomb.common.rest.codec.param.QueryProcessorCreator.QueryProcessor;
+import io.servicecomb.common.rest.codec.QueryProcessorFactory.CsvQueryProcessor;
+import io.servicecomb.common.rest.codec.QueryProcessorFactory.MultiQueryProcessor;
+import io.servicecomb.common.rest.codec.QueryTypeEnum;
import io.swagger.models.parameters.Parameter;
import io.swagger.models.parameters.QueryParameter;
+import mockit.Mock;
+import mockit.MockUp;
public class TestQueryProcessorCreator {
@Test
@@ -34,6 +37,17 @@ public void testCreate() {
ParamValueProcessor processor = creator.create(parameter, String.class);
- Assert.assertEquals(QueryProcessor.class, processor.getClass());
+ Assert.assertEquals(MultiQueryProcessor.class, processor.getClass());
+
+ new MockUp<QueryParameter>(){
+ @Mock
+ protected String getCollectionFormat(){
+ return String.valueOf(QueryTypeEnum.csv);
+ }
+ };
+ ParamValueProcessor processor1 = creator.create(parameter, String.class);
+
+ Assert.assertEquals(CsvQueryProcessor.class, processor1.getClass());
+
}
}
diff --git a/demo/demo-springmvc/springmvc-client/src/main/java/io/servicecomb/demo/springmvc/client/CodeFirstRestTemplateSpringmvc.java b/demo/demo-springmvc/springmvc-client/src/main/java/io/servicecomb/demo/springmvc/client/CodeFirstRestTemplateSpringmvc.java
index 63ecca620..7444ae61d 100644
--- a/demo/demo-springmvc/springmvc-client/src/main/java/io/servicecomb/demo/springmvc/client/CodeFirstRestTemplateSpringmvc.java
+++ b/demo/demo-springmvc/springmvc-client/src/main/java/io/servicecomb/demo/springmvc/client/CodeFirstRestTemplateSpringmvc.java
@@ -181,4 +181,10 @@ protected void testCodeFirstTestForm(RestTemplate template, String cseUrlPrefix)
map.put("form2", "");
TestMgr.check(code + "", template.postForEntity(cseUrlPrefix + "/testform", formEntiry, String.class).getBody());
}
+
+ @Override
+ protected void testCodeFirstIsTrue(RestTemplate template, String cseUrlPrefix) {
+ String result = template.getForObject(cseUrlPrefix + "testStrArray?str=a1,b1,c1", String.class);
+ TestMgr.check("ok", result);
+ }
}
diff --git a/demo/demo-springmvc/springmvc-server/src/main/java/io/servicecomb/demo/springmvc/server/CodeFirstSpringmvc.java b/demo/demo-springmvc/springmvc-server/src/main/java/io/servicecomb/demo/springmvc/server/CodeFirstSpringmvc.java
index 3fc76aab7..7db3f07af 100644
--- a/demo/demo-springmvc/springmvc-server/src/main/java/io/servicecomb/demo/springmvc/server/CodeFirstSpringmvc.java
+++ b/demo/demo-springmvc/springmvc-server/src/main/java/io/servicecomb/demo/springmvc/server/CodeFirstSpringmvc.java
@@ -65,6 +65,7 @@
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ResponseHeader;
@@ -311,4 +312,17 @@ public String testform(HttpServletRequest request) {
Assert.notNull(form1);
return form1 + form2;
}
+
+ @RequestMapping(path = "/testStrArray", method = RequestMethod.GET)
+ public String testStrArray(@ApiParam(collectionFormat = "csv") String[] str){
+ try {
+ for (int i = 0; i < str.length; i++) {
+ System.out.println(str.length + "*****" + str[i] + "\n");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return "ok";
+ }
+
}
diff --git a/swagger/swagger-generator/generator-core/src/main/java/io/servicecomb/swagger/generator/core/processor/parameter/AbstractParameterProcessor.java b/swagger/swagger-generator/generator-core/src/main/java/io/servicecomb/swagger/generator/core/processor/parameter/AbstractParameterProcessor.java
index 8d125d059..5074d8efe 100644
--- a/swagger/swagger-generator/generator-core/src/main/java/io/servicecomb/swagger/generator/core/processor/parameter/AbstractParameterProcessor.java
+++ b/swagger/swagger-generator/generator-core/src/main/java/io/servicecomb/swagger/generator/core/processor/parameter/AbstractParameterProcessor.java
@@ -20,6 +20,7 @@
import io.servicecomb.swagger.generator.core.OperationGenerator;
import io.servicecomb.swagger.generator.core.ParameterAnnotationProcessor;
import io.servicecomb.swagger.generator.core.utils.ParamUtils;
+import io.swagger.annotations.ApiParam;
import io.swagger.models.parameters.AbstractSerializableParameter;
public abstract class AbstractParameterProcessor<T extends AbstractSerializableParameter<?>>
@@ -35,8 +36,8 @@ public void process(Object annotation, OperationGenerator operationGenerator, in
protected void fillParameter(Object annotation, OperationGenerator operationGenerator, int paramIdx,
T parameter) {
- setParameterName(annotation, operationGenerator, paramIdx, parameter);
setParameterType(operationGenerator, paramIdx, parameter);
+ setParameterName(annotation, operationGenerator, paramIdx, parameter);
}
protected void setParameterType(OperationGenerator operationGenerator, int paramIdx,
@@ -52,9 +53,14 @@ protected void setParameterName(Object annotation, OperationGenerator operationG
String paramName = getAnnotationParameterName(annotation);
paramName = ParamUtils.getParameterName(paramName, operationGenerator.getProviderMethod(), paramIdx);
parameter.setName(paramName);
+ parameter.setCollectionFormat(getAnnotationParameterColFmt(annotation));
}
protected abstract T createParameter();
protected abstract String getAnnotationParameterName(Object annotation);
+
+ protected String getAnnotationParameterColFmt(Object annotation) {
+ return null;
+ }
}
diff --git a/swagger/swagger-generator/generator-springmvc/src/main/java/io/servicecomb/swagger/generator/springmvc/SpringmvcSwaggerGeneratorContext.java b/swagger/swagger-generator/generator-springmvc/src/main/java/io/servicecomb/swagger/generator/springmvc/SpringmvcSwaggerGeneratorContext.java
index b9503edba..608ba75e0 100644
--- a/swagger/swagger-generator/generator-springmvc/src/main/java/io/servicecomb/swagger/generator/springmvc/SpringmvcSwaggerGeneratorContext.java
+++ b/swagger/swagger-generator/generator-springmvc/src/main/java/io/servicecomb/swagger/generator/springmvc/SpringmvcSwaggerGeneratorContext.java
@@ -36,6 +36,7 @@
import io.servicecomb.swagger.generator.core.utils.ClassUtils;
import io.servicecomb.swagger.generator.rest.RestSwaggerGeneratorContext;
+import io.servicecomb.swagger.generator.springmvc.processor.annotation.ApiParamAnnotationProcessor;
import io.servicecomb.swagger.generator.springmvc.processor.annotation.CookieValueAnnotationProcessor;
import io.servicecomb.swagger.generator.springmvc.processor.annotation.DeleteMappingMethodAnnotationProcessor;
import io.servicecomb.swagger.generator.springmvc.processor.annotation.GetMappingMethodAnnotationProcessor;
@@ -52,6 +53,7 @@
import io.servicecomb.swagger.generator.springmvc.processor.annotation.RequestPartAnnotationProcessor;
import io.servicecomb.swagger.generator.springmvc.processor.parameter.SpringmvcDefaultParameterProcessor;
import io.servicecomb.swagger.generator.springmvc.processor.response.ResponseEntityProcessor;
+import io.swagger.annotations.ApiParam;
public class SpringmvcSwaggerGeneratorContext extends RestSwaggerGeneratorContext {
private static final int ORDER = 1000;
@@ -106,6 +108,7 @@ protected void initParameterAnnotationMgr() {
parameterAnnotationMgr.register(RequestParam.class, new RequestParamAnnotationProcessor());
parameterAnnotationMgr.register(RequestAttribute.class, new RequestAttributeAnnotationProcessor());
parameterAnnotationMgr.register(RequestPart.class, new RequestPartAnnotationProcessor());
+ parameterAnnotationMgr.register(ApiParam.class, new ApiParamAnnotationProcessor());
}
@Override
diff --git a/swagger/swagger-generator/generator-springmvc/src/main/java/io/servicecomb/swagger/generator/springmvc/processor/annotation/ApiParamAnnotationProcessor.java b/swagger/swagger-generator/generator-springmvc/src/main/java/io/servicecomb/swagger/generator/springmvc/processor/annotation/ApiParamAnnotationProcessor.java
new file mode 100644
index 000000000..1122a5139
--- /dev/null
+++ b/swagger/swagger-generator/generator-springmvc/src/main/java/io/servicecomb/swagger/generator/springmvc/processor/annotation/ApiParamAnnotationProcessor.java
@@ -0,0 +1,25 @@
+package io.servicecomb.swagger.generator.springmvc.processor.annotation;
+
+
+import javax.ws.rs.QueryParam;
+
+import io.servicecomb.swagger.generator.core.processor.parameter.AbstractParameterProcessor;
+import io.swagger.annotations.ApiParam;
+import io.swagger.models.parameters.QueryParameter;
+
+public class ApiParamAnnotationProcessor extends AbstractParameterProcessor<QueryParameter> {
+ @Override
+ protected QueryParameter createParameter() {
+ return new QueryParameter();
+ }
+
+ @Override
+ protected String getAnnotationParameterName(Object annotation) {
+ return ((ApiParam) annotation).value();
+ }
+
+ @Override
+ protected String getAnnotationParameterColFmt(Object annotation) {
+ return ((ApiParam) annotation).collectionFormat();
+ }
+}
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services