如何为具有多个同名查询参数的 api 编写伪装客户端?

How to write a feign client for an api that has multiple identically named query params?

我正在尝试编写一个假客户端来调用以从服务器检索数据,其中 api 接受相同命名的查询参数列表以确定要询问的数据量。这是一个示例 url 我正在尝试点击:

http://some-server/some-endpoint/{id}?include=profile&include=account&include=address&include=email

到目前为止,对于我的假装客户,我正在尝试以这种方式进行设置:

@FeignClient("some-server")
public interface SomeServerClient {
  @RequestMapping(method = RequestMethod.GET,
      value = "/customers/api/customers/{id}",
      produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  Map<Object, Object> queryById(
      @PathVariable long id,
      @RequestParam("include[]") String ... include);

  default Map<Object, Object> queryById(long id) {
    return queryById(id,"profile", "account", "address", "email");
  }

然而,这似乎并没有按照所需的方式格式化请求,所以我的问题是如何设置我的假客户端以将其请求提交给 url,如上例所示?

使用 @RequestParam("include") List<String> includes,示例:

客户端:

@FeignClient(value = "foo-client")
public interface FooClient {

    @GetMapping("/foo")
    Foo getFoo(@RequestParam("include") List<String> includes);

}

控制器:

@RestController
public class FooController {

    @GetMapping("/foo")
    public Foo getFoo(@RequestParam("include") List<String> includes) {
        return new Foo(includes);
    }

}

用法:

List<String> includes = new ArrayList<>();
        includes.add("foo");
        includes.add("bar");

        Foo foo = fooClient.getFoo(includes);

url:

http://some-server/foo?include=foo&include=bar