Ho... We have to update this part of documentation. The wrapper solution works but doesn't fit APIs.
If you're looking at the generated code for @Get("url") MyReturnedType testService()
, you should see something like this :
return restTemplate.exchange(rootUrl.concat("url"), //
HttpMethod.GET, //
null, //
MyReturnedType.class, //
urlVariables)//
.getBody();
The returned class is injected as a parameter of exchange
call. In case of generics collection (like List<MyReturnedType>
), we can't inject List.class
because of type checking in the return of exchange method.
However, you should be able to use this little trick in your @Rest
annotated method :
public class BookmarkList extends List<Bookmark> {
}