feign icon indicating copy to clipboard operation
feign copied to clipboard

Passing multiple objects as request parameters

Open Mafinorr opened this issue 1 year ago • 1 comments

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&regionId=er&email=wef%40dfwdf.ru&waitListTopic=SOMETOPIC

Mafinorr avatar Jun 14 '23 12:06 Mafinorr

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.

gary258796 avatar Jun 17 '23 15:06 gary258796