Optional request body should be supported by feign
See original GitHub issueIn Spring MVC it is possible to annotate body parameter as optional using @RequestBody(required = false) parameter annotation, e.g.:
@FeignClient("foo-service")
public interface FooService {
@RequestMapping(value = "/foo", method = RequestMethod.POST)
void doFoo(@RequestBody(required = false) FilterDto filter);
}
However, Spring-Feign contract does not consider the optionality flag which leads to an IllegalStateException on proxy bootstrapping in consumer when calling something like:
fooService.doFoo(null);
java.lang.IllegalArgumentException: Body parameter 0 was null
at feign.Util.checkArgument(Util.java:102)
at feign.ReflectiveFeign$BuildEncodedTemplateFromArgs.resolve(ReflectiveFeign.java:323)
at feign.ReflectiveFeign$BuildTemplateByResolvingArgs.create(ReflectiveFeign.java:213)
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:72)
at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103)
It is expected that null can be passed as parameter since it is optional.
Using:
- spring-cloud-starter-feign:1.1.0.RELEASE
- feign-core:8.16.2
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Optional request body should be supported by feign · Issue #126
In Spring MVC it is possible to annotate body parameter as optional using @RequestBody(required = false) parameter annotation, ...
Read more >Feign client support for optional request param - Stack Overflow
For example, I have an endpoint, but I am not finding a way to actually make the param1 optional using feign client. @GetMapping(path...
Read more >Developers - Optional request body should be supported by feign -
In Spring MVC it is possible to annotate body parameter as optional using @RequestBody(required = false) parameter annotation, e.g.:
Read more >Spring Cloud OpenFeign
Feign is a declarative web service client. It makes writing web service clients easier. To use Feign create an interface and annotate it....
Read more >How to configure fiegn clients to perform HTTP requests in ...
In this tutorial, we will discuss how to configure and customize OpenFeign clients to perform the HTTP functions GET, PUT, POST & DELETE....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@spencergibb: Do you think you can drop a line and explain why this issue has been closed without any further comment?
@sdhery https://github.com/OpenFeign/feign/pull/583 has not been accept,so you need compile feign by yourself,then write an
RequestBodyParameterProcessorimplementsAnnotatedParameterProcessorinterface to support this issue