Commit 919c8fa7 by Ryan Baxter Committed by GitHub

Merge pull request #1678 from lowzj/master-RequestParam

fix gh-1672, support @RequestParam without a value
parents bcb97bce c8fded80
...@@ -28,7 +28,6 @@ import java.util.LinkedHashMap; ...@@ -28,7 +28,6 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.beans.BeanUtils;
import org.springframework.cloud.netflix.feign.AnnotatedParameterProcessor; import org.springframework.cloud.netflix.feign.AnnotatedParameterProcessor;
import org.springframework.cloud.netflix.feign.annotation.PathVariableParameterProcessor; import org.springframework.cloud.netflix.feign.annotation.PathVariableParameterProcessor;
import org.springframework.cloud.netflix.feign.annotation.RequestHeaderParameterProcessor; import org.springframework.cloud.netflix.feign.annotation.RequestHeaderParameterProcessor;
...@@ -324,9 +323,7 @@ public class SpringMvcContract extends Contract.BaseContract ...@@ -324,9 +323,7 @@ public class SpringMvcContract extends Contract.BaseContract
// has a parameter name // has a parameter name
return parameterNames != null && parameterNames.length > parameterIndex return parameterNames != null && parameterNames.length > parameterIndex
// has a type // has a type
&& parameterTypes != null && parameterTypes.length > parameterIndex && parameterTypes != null && parameterTypes.length > parameterIndex;
// and it is a simple property
&& BeanUtils.isSimpleProperty(parameterTypes[parameterIndex].getClass());
} }
private class SimpleAnnotatedParameterContext private class SimpleAnnotatedParameterContext
......
...@@ -298,6 +298,19 @@ public class SpringMvcContractTests { ...@@ -298,6 +298,19 @@ public class SpringMvcContractTests {
} }
@Test @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 { public void testProcessAnnotations_MapParams() throws Exception {
Method method = TestTemplate_MapParams.class.getDeclaredMethod("getTest", Method method = TestTemplate_MapParams.class.getDeclaredMethod("getTest",
Map.class); Map.class);
...@@ -457,6 +470,11 @@ public class SpringMvcContractTests { ...@@ -457,6 +470,11 @@ public class SpringMvcContractTests {
ResponseEntity<TestObject> getTest(@RequestParam("id") List<String> id); 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 { public interface TestTemplate_MapParams {
@RequestMapping(value = "/test", method = RequestMethod.GET) @RequestMapping(value = "/test", method = RequestMethod.GET)
ResponseEntity<TestObject> getTest(@RequestParam Map<String, String> params); ResponseEntity<TestObject> getTest(@RequestParam Map<String, String> params);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment