I'm facing the following issue and have been able to find a proper fix.
As a use case example, let's imagine a Rest client that fetches a json object from a server, where the request is the path to the object. This api does not accept query parameters nor bodies, and no catalogue is available.
say that I have the following RestClient:
@Path("/json")
@RegisterRestClient(configKey="json-api")
public interface JsonService {
@GET
@Path("/{MyVariableLengthEndpoint}")
Response getJson(@PathParam("MyVariableLengthEndpoint") ????? endpoint);
}
Examples of requests could be :
/json/employees/Dwight/jobs/assistantRegionalManager/salary
/json/games/theLastOfUs/rating
Passing a string with / characters gets encoded with %. To bypass this, I've tried:
- Using the @Encoded annotation
- Adding a regex in the pathParameter
{MyVariableLengthEndpoint: .*}
- Passing a
List<PathSegment>
None of those worked.
Is there a proper way to do this ?