feign
feign copied to clipboard
Passing multiple objects as request parameters
Hello, is there a way to pass multiple objects parameters to interface and get all fields as query params ?
Example:
Interface:
@RequestLine("POST /api/v1/pc/customers/{customerId}/wait?{pagination, filter}")
void doSomething(@Param("customerId") long customerId, @QueryMap("pagination") Pagination pagination, @QueryMap("filter") WaitListFilter filter);
Models:
class Pagination {
private int offset;
private int limit;
.....
}
public class WaitListFilter {
private String productId;
private String deviceUuid;
private String regionId;
private String email;
private WaitListTopic waitListTopic; //this in an enum
}
And result request would be:
{host}/api/v1/pc/customers/1/wait?offset=2&limit=3&productId=123&deviceUuid=sdfsdf®ionId=er&email=wef%40dfwdf.ru&waitListTopic=SOMETOPIC
This might be same as @ 2018 .
The workaround is to have a object , say its name is 'TempObj' , that have your 'Pagination' and 'WaitListFilter' as fields, then use Expander to customize how TempObj be transformed to query string.