Search code examples
swaggernetflix-feignspring-cloud-feignswagger-codegen

How to ignore @FeignClient apis from being processed by swagger?


I am using swagger and Feign in one project, and the swagger will take @RequestMapping annotated methods and create the documentation. But this is weird to do so for classes and methods annotated by both @FeightClient and @RequestMapping. So how to ignore these apis in swagger? Which class of swagger do the scan job so that I could learn and add some other class to ignore these apis annotated by @FeightClient?

@FeignClient(name = TodoItemRpcRepository.SERVICE_NAME)
@RequestMapping("/api/todos")
public interface TodoItemRpcRepository {

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
  TodoItem findById(@RequestHeader("X-Auth-Token") final String token,  //
      @PathVariable("id") final Long id);
}

Solution

  • I removed the @RequestMapping over the @FeignClient annotated class and add a path attribute in the @FeignClient. This time, issue was resolved perfectly. I guess @RequestMapping is not permitted to @FeignClient annotated class.

    @FeignClient(name = TodoItemRpcRepository.SERVICE_NAME, name="/api/todos")
    public interface TodoItemRpcRepository {
    
    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
      TodoItem findById(@RequestHeader("X-Auth-Token") final String token,  //
          @PathVariable("id") final Long id);
    }