Search code examples
spring-bootopenfeign

How ignore not annoted methods using OpenFeign SpringMvcContract


I'm using swagger-codegen to genrate the interface for my Feign Client.

However the swagger-codegen generates these methods :

Optional<ObjectMapper> getObjectMapper();

Optional<HttpServletRequest> getRequest();

And when I run my application I receive this excpetion:

FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Method getRequest not annotated with HTTP method type (ex. GET, POST)

I want to add to my FeignConfig something that tells to ignore the getObjectMapper(), getRequest() from my interface!

Is this possible ?


Solution

  • To solve the issue, I just added default for getObjectMapper(), getRequest().

    @Override 
    default Optional<ObjectMapper> getObjectMapper() {
        return Optional.empty();
    }
    
    @Override 
    default Optional<HttpServletRequest> getRequest() {
        return Optional.empty();
    }