artiya4u / google-http-java-client

Automatically exported from code.google.com/p/google-http-java-client
0 stars 0 forks source link

UriTemplate doesnt expand UUID annotated as @Key #252

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-http-java-client (e.g. 1.15.0-rc)?
v1.17.0-rc

Java environment (e.g. Java 6, Android 2.3, App Engine)?
Android 4.4

Describe the problem.
private static final String BASE_URL = "http://www.example.com/";
private static final String REST_PATH = "user/{userId}/posts";
@Key("userId") private final UUID mUserId = UUID.randomUUID();
...
UriTemplate.expand(BASE_URL, REST_PATH, this, true);

produces the following result:

http://www.example.com/user//posts

How would you expect it to be fixed?
The result should be similar to the following:
http://www.example.com/user/00000000-0000-0000-0000-000000000001/posts

Interestingly, if you omit {userId} from the template and just let it expand as 
a query parameter instead by setting addUnusedParamsAsQueryParams to true, then 
it works fine:
http://www.example.com/user/posts?userId=00000000-0000-0000-0000-000000000001

Original issue reported on code.google.com by gurmeet....@codewiresoftware.com on 11 Dec 2013 at 11:37