Commit 62d340bc by Spencer Gibb

Support @AliasFor annotation elements in Feign.

fixes gh-766
parent 9287e66c
...@@ -33,12 +33,13 @@ import org.springframework.cloud.netflix.feign.annotation.RequestParamParameterP ...@@ -33,12 +33,13 @@ import org.springframework.cloud.netflix.feign.annotation.RequestParamParameterP
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import static feign.Util.checkState;
import static feign.Util.emptyToNull;
import feign.Contract; import feign.Contract;
import feign.MethodMetadata; import feign.MethodMetadata;
import static feign.Util.checkState;
import static feign.Util.emptyToNull;
import static org.springframework.core.annotation.AnnotatedElementUtils.findMergedAnnotation;
/** /**
* @author Spencer Gibb * @author Spencer Gibb
*/ */
...@@ -73,7 +74,7 @@ public class SpringMvcContract extends Contract.BaseContract { ...@@ -73,7 +74,7 @@ public class SpringMvcContract extends Contract.BaseContract {
public MethodMetadata parseAndValidateMetadata(Class<?> targetType, Method method) { public MethodMetadata parseAndValidateMetadata(Class<?> targetType, Method method) {
MethodMetadata md = super.parseAndValidateMetadata(targetType, method); MethodMetadata md = super.parseAndValidateMetadata(targetType, method);
RequestMapping classAnnotation = targetType.getAnnotation(RequestMapping.class); RequestMapping classAnnotation = findMergedAnnotation(targetType, RequestMapping.class);
if (classAnnotation != null) { if (classAnnotation != null) {
// Prepend path from class annotation if specified // Prepend path from class annotation if specified
if (classAnnotation.value().length > 0) { if (classAnnotation.value().length > 0) {
...@@ -111,7 +112,7 @@ public class SpringMvcContract extends Contract.BaseContract { ...@@ -111,7 +112,7 @@ public class SpringMvcContract extends Contract.BaseContract {
return; return;
} }
RequestMapping methodMapping = RequestMapping.class.cast(methodAnnotation); RequestMapping methodMapping = findMergedAnnotation(method, RequestMapping.class);
// HTTP Method // HTTP Method
checkOne(method, methodMapping.method(), "method"); checkOne(method, methodMapping.method(), "method");
data.template().method(methodMapping.method()[0].name()); data.template().method(methodMapping.method()[0].name());
......
...@@ -162,7 +162,7 @@ public class SpringMvcContractTest { ...@@ -162,7 +162,7 @@ public class SpringMvcContractTest {
public interface TestTemplate_Advanced { public interface TestTemplate_Advanced {
@ExceptionHandler @ExceptionHandler
@RequestMapping(value = "/test/{id}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(path = "/test/{id}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<TestObject> getTest(@RequestHeader("Authorization") String auth, ResponseEntity<TestObject> getTest(@RequestHeader("Authorization") String auth,
@PathVariable("id") String id, @RequestParam("amount") Integer amount); @PathVariable("id") String id, @RequestParam("amount") Integer amount);
......
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