-
Notifications
You must be signed in to change notification settings - Fork 798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional request body should be supported by feign #126
Comments
From the stack trace you should understand that this issue is a pure Feign problem. Spring Cloud Netflix facilitate Netflix OSS component integration into Spring. I would suggest you to open an issue on the feign project. |
@daniellavoie, thanks for your feedback. Indeed, initially I was about to open this issue on the Feign project (because of the reasons admitted by you) but stack traces should not be always interpreted literally. Basically it seems not like a "a pure Feign problem" for me. Please correct me if I am wrong but:
In fact, there might be currently no way in Feign to handle optional request bodies. However, this behavior should be at least documented in this project (because of the difference to behavior anticipated in Spring MVC). Further, it might be considered to create a certain RequestBodyParameterProcessor which catches the issue one level higher before letting Feign to throw semi-reasonable exception. |
You are right. Looks like I had a bad understanding of Spring Cloud Feign. I'll try to have a look and see if I can come up with a trick to handle an optinal parameter. If you have any inspiration, feel free to give some help ;) |
@spencergibb: Do you think you can drop a line and explain why this issue has been closed without any further comment? |
Sorry about that, it was a mistake. |
Hello @spencergibb, any update on this issues? |
@realdammy it is labeled as an enhancement but as far as I know no one is working on it at the moment. If you want to submit a PR for it that would be more than welcome. |
@ryanjbaxter I try to fix this issue. But feign always check the body, so I have to wait this PR : OpenFeign/feign#583. @Override
protected RequestTemplate resolve(Object[] argv, RequestTemplate mutable, Map<String, Object> variables) {
Object body = argv[metadata.bodyIndex()];
checkArgument(body != null, "Body parameter %s was null", metadata.bodyIndex());
...
return super.resolve(argv, mutable, variables);
} If this PR can be accept. I will create another PR for here. @dimw Thanks for your analysis. |
Already have a solution? |
@sdhery OpenFeign/feign#583 has not been accept,so you need compile feign by yourself,then write an |
In Spring MVC it is possible to annotate body parameter as optional using
@RequestBody(required = false)
parameter annotation, e.g.:However, Spring-Feign contract does not consider the optionality flag which leads to an IllegalStateException on proxy bootstrapping in consumer when calling something like:
It is expected that
null
can be passed as parameter since it is optional.Using:
The text was updated successfully, but these errors were encountered: