Let’s say I’m given the below endpoint:
GET /hello/{id}?idType={idType}
where the allowed values of idType are [“loginId”, “contactId”]
I have to consume this service using:
@HttpExchange("/hello")
public interface HelloClient {
@GetExchange("/{id}")
String hello(@PathVariable String id, @RequestParam IdType idType);
}
where IdType is an enum:
public enum IdType {
LOGIN_ID("loginId"),
CONTACT_ID("contactId");
String idType;
IdType(String idType) { this.idType = idType; }
}
normally one could define a Converter<IdType, String> bean I guess and spring would use that to do it’s magic and send the correct request:
GET /hello/xyz?idType=loginId
How can I do the same with HttpInterfaces?
helloClient.hello("xyz", IdType.LOGIN_ID);
expected: GET /hello/xyz?idType=loginId
actual: GET /hello/xyz?idType=LOGIN_ID
I don’t want to have this code:
helloClient.hello("xyz", IdType.LOGIN_ID.getIdType());
Is something like this possible? Converter doesn’t seem to be used.