Merge pull request #1678 from lowzj/master-RequestParam
fix gh-1672, support @RequestParam without a value
This commit is contained in:
@@ -28,7 +28,6 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.cloud.netflix.feign.AnnotatedParameterProcessor;
|
||||
import org.springframework.cloud.netflix.feign.annotation.PathVariableParameterProcessor;
|
||||
import org.springframework.cloud.netflix.feign.annotation.RequestHeaderParameterProcessor;
|
||||
@@ -324,9 +323,7 @@ public class SpringMvcContract extends Contract.BaseContract
|
||||
// has a parameter name
|
||||
return parameterNames != null && parameterNames.length > parameterIndex
|
||||
// has a type
|
||||
&& parameterTypes != null && parameterTypes.length > parameterIndex
|
||||
// and it is a simple property
|
||||
&& BeanUtils.isSimpleProperty(parameterTypes[parameterIndex].getClass());
|
||||
&& parameterTypes != null && parameterTypes.length > parameterIndex;
|
||||
}
|
||||
|
||||
private class SimpleAnnotatedParameterContext
|
||||
|
||||
@@ -297,6 +297,19 @@ public class SpringMvcContractTests {
|
||||
assertNotNull(data.indexToExpander().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessAnnotations_ListParamsWithoutName() throws Exception {
|
||||
Method method = TestTemplate_ListParamsWithoutName.class.getDeclaredMethod("getTest",
|
||||
List.class);
|
||||
MethodMetadata data = this.contract
|
||||
.parseAndValidateMetadata(method.getDeclaringClass(), method);
|
||||
|
||||
assertEquals("/test", data.template().url());
|
||||
assertEquals("GET", data.template().method());
|
||||
assertEquals("[{id}]", data.template().queries().get("id").toString());
|
||||
assertNotNull(data.indexToExpander().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProcessAnnotations_MapParams() throws Exception {
|
||||
Method method = TestTemplate_MapParams.class.getDeclaredMethod("getTest",
|
||||
@@ -457,6 +470,11 @@ public class SpringMvcContractTests {
|
||||
ResponseEntity<TestObject> getTest(@RequestParam("id") List<String> id);
|
||||
}
|
||||
|
||||
public interface TestTemplate_ListParamsWithoutName {
|
||||
@RequestMapping(value = "/test", method = RequestMethod.GET)
|
||||
ResponseEntity<TestObject> getTest(@RequestParam List<String> id);
|
||||
}
|
||||
|
||||
public interface TestTemplate_MapParams {
|
||||
@RequestMapping(value = "/test", method = RequestMethod.GET)
|
||||
ResponseEntity<TestObject> getTest(@RequestParam Map<String, String> params);
|
||||
|
||||
Reference in New Issue
Block a user