Describe the bug Rest API Interface with inheritance, the @RequestMapping annotation will be ignored.

Sample

public interface Foo {

}

@RequestMapping(path="/bar")
public interface Bar extends Foo{
  @GetMapping("xxx")
  Object someMethod();
}

if i use Bar as interface to generate a feign client, the uri call to someMethod will lose "/bar"

I checked the code, and quiet confused with the code in org.springframework.cloud.openfeign.support.SpringMvcContract$processAnnotationOnClass that clz.getInterfaces().length == 0


    @Override
    protected void processAnnotationOnClass(MethodMetadata data, Class<?> clz) {
        if (clz.getInterfaces().length == 0) {
        ...

the call to this method has already handled inheriance: code in feign.Contract

    protected MethodMetadata parseAndValidateMetadata(Class<?> targetType, Method method) {
      final MethodMetadata data = new MethodMetadata();
      data.targetType(targetType);
      data.method(method);
      data.returnType(Types.resolve(targetType, targetType, method.getGenericReturnType()));
      data.configKey(Feign.configKey(targetType, method));

      if (targetType.getInterfaces().length == 1) {
        processAnnotationOnClass(data, targetType.getInterfaces()[0]);
      }
      processAnnotationOnClass(data, targetType);
     ...

I think the statement if (clz.getInterfaces().length == 0) org.springframework.cloud.openfeign.support.SpringMvcContract$processAnnotationOnClass may be removed.

Comment From: cbezmen

Hi @sialais,

Please read gh-564

Comment From: sialais

Hi @sialais,

Please read gh-564

Hi, @cbezmen , I have read gh-564 before, but I do not think they are the same problem.

Take notice that, there's no annotation on parent interface, and @FeignClient annotation is not the only way using feign. (we can also use FeignClientBuiilder, @RequestMapping is a way to keep service impl iconsistent with rest api )

by the way, the way fix this problem is also quite simple. I'd like to make a pr if agreed.

Comment From: cbezmen

if i use Bar as interface to generate a feign client, the uri call to someMethod will lose "/bar"

When I read this. I think you will use Bar class as interface to your FeignClient. In Feign path variable is used to define path and There is no way to inherit it. As @OlgaMaciaszek mentioned here, I think you can't use @RequestMapping annotation on inherited interface of FeignClient.

Comment From: sialais

if i use Bar as interface to generate a feign client, the uri call to someMethod will lose "/bar"

When I read this. I think you will use Bar class as interface to your FeignClient. In Feign path variable is used to define path and There is no way to inherit it. As @OlgaMaciaszek mentioned here, I think you can't use @RequestMapping annotation on inherited interface of FeignClient.

Yes, Bar is the interface of FeignClient, and path variable is not inherited from Foo. Foo can be some interface just to mark, like Serializable, and this inheritance will make @RequestMapping be ignored.

Comment From: sialais

By the way, I think it is resonable to use @RequestMapping annotation on child interface and ignore annotation on parent interface if the annotation both on child and parent. (@RequestMapping can be overrided), as the way url mapping in springMVC.

Comment From: OlgaMaciaszek

Yes, as @cbezmen has noted, this is not advisable and not supported. Please see the note at the end of this section.