Add the ability to pass request parameters as object - #636
Conversation
* Adds an encoder using a parameter object to add query parameters to the request from its non null properties ** encore introspects the object to find getters ** only add parameters to the query if the value is non null * Does not require to add any annotation in the parameter object class (sometime you don't have this possibility; as with external libs) Fixes OpenFeign#520
|
❓ where should I amend the documentation about this new |
|
Documentation added |
|
I'm new to feign, so I may be missing something obvious, but... Since this is expanding query parameters objects, rather than request body objects, shouldn't this be an |
|
Here is another attempt at a solution by someone else that uses a fallback encoder: It would be nice if encoders were typed and had a |
|
@smougenot Would #667 work for you? It should allow you to create your ObjectToQueryParamEncoder class locally and include it via: @CustomParam(encoder = ObjectToQueryParamEncoder.class) MyCustomObject myCustomObjectThat PR allows your custom encoder to modify query params (as your class is doing) or headers (we needed to use param context in generating our auth headers as well) or whatever you need (as with custom encoders and interceptors, use at your own risk since you can totally mangle everything in the template if you screw something up). I'd like to find something that would work for you, me, #620 and anyone else who needs something similar (this might even solve #601 if it doesn't need to be run again on every retry). |
|
@smougenot, #667 has been changed to work with POJOs by using field names as parameter names and field values as parameter values. The new usage is just: @QueryMap MyCustomObject myCustomObject...and your custom object will have to use fields ( |
|
Looks fine (I didn't gave it a try) But you still rely on injecting annotation. |
Fixes #520