3

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 ?

Mohamed Taboubi
  • 6,663
  • 11
  • 55
  • 87
  • If I can say to my SpringMvcContract to ignore some methods, it will resolve my issue - I think! – Mohamed Taboubi Apr 13 '20 at 18:55
  • Have you found a solution? Im facing the same problem. I have tried many many things autoconfiguring. I shouldn't be recreating a feign client in my controllers that host the feign clients to make subsequent calls. It should be plug and play so to say, yet swagger keeps generating feign client apis with empty getObjectMapper and getRequest methods. Have you found a solution? – Alex Dec 23 '20 at 17:43
  • My solution was just to write another interface with the methods I want... – Mohamed Taboubi Dec 23 '20 at 17:45
  • So then you are not generating openfeign clients with swagger no? You create them manualy. Is that so? – Alex Dec 23 '20 at 17:47
  • For this specific client no, i just write my own interface unfortunately! Just because the issue mentioned above! – Mohamed Taboubi Dec 23 '20 at 17:48
  • Yes. It doesn't make sense. As I said, clients should be plug and play. I don't understand why the objectmapper and other methods are empty. We shouldn't be forced to use a Builder or new contract – Alex Dec 23 '20 at 18:24
  • Yes! I agree!, it should be able to ignore the not annotated methods! – Mohamed Taboubi Dec 23 '20 at 18:27

1 Answers1

1

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();
}