Я пытаюсь запросить API https://transport.opendata.ch/.В этом API можно фильтровать ответ, чтобы избежать большой полезной нагрузки (используя ?fields[]=...
).
Например: http://transport.opendata.ch/v1/connections?from=Lausanne&to=Zurich&fields[]=connections/from&fields[]=connections/to
Я использую Spring Boot и Feign, вот мой код:
@FeignClient(value = "transport", url = "${transport.url}")
public interface TransportClient {
@RequestMapping(method = GET, value = "/connections", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
Connections getConnections(@RequestParam("from") String from, @RequestParam("to") String to, @RequestParam("fields[]") String[] fields);
default Connections getConnections(String from, String to) {
return getConnections(from, to, new String[] {"connections/from", "connections/to"});
}
}
Проблема заключается в сгенерированном запросе:
http://transport.opendata.ch/v1/connections?from=Lausanne&to=Zurich&fields%5B%5D=connections%2Ffrom%2Cconnections%2Fto
Как видите, URL закодирован, а массив неправильно привязан (используется запятая вместо нескольких fields
в URL).
IsЕсть ли способ добиться этого?Если это невозможно сделать с помощью FeignClient (Spring), возможно, с помощью Feign это возможно?
Спасибо за помощь.