[aerogear-dev] REST-based API Versioning

tolis emmanouilidis tolisemm at gmail.com
Tue Sep 2 03:27:38 EDT 2014


Hi Eric,

I have tried the jax-rs @Produces annotation both at method and class
levels as shown here (
http://docs.oracle.com/cd/E19798-01/821-1841/gipzh/index.html) and it works
for me. I don't have to specify the Content-Type header in the request.The
resource method or endpoint is chosen according the Accept header.

method level

@GET
@Produces({"application/vnd.aerogear.v101+json"})
public List<Member> listAllMembers() {
    return repository.findAllOrderedByName();
}


@GET
@Produces({"application/vnd.aerogear.v102+json"})
public List<Member> listAllMembersNew() {
    return null;
}

class level

@Path("/members")
@RequestScoped
@Produces({"application/vnd.aerogear.v102+json"})
public class MemberResourceRESTServiceV102 {

@Path("/members")
@RequestScoped
@Produces({"application/vnd.aerogear.v101+json"})
public class MemberResourceRESTService {



2014-09-02 9:24 GMT+03:00 Erik Jan de Wit <edewit at redhat.com>:

>
> Could you try the @produces annotation?
>
>
> Same effect
>
>
> I believe it will work with the Accept header since it indicates the
> acceptable media-types from the client
>
>
> 2014-09-01 14:33 GMT+03:00 Erik Jan de Wit <edewit at redhat.com>:
>
>>
>> Another option that might work out of the box would be to use the jax-rs
>> @Consumes annotation e.g @Consumes({"application/vnd.aerogear.v101+json"})
>> on the service endpoints.
>> So by making an abstract PushNotificationSenderEndpoint and and several
>> PushNotificationSenderEndpointV101, PushNotificationSenderEndpointV102 with
>> the right @Consumes annotation should work. I haven't tried it though
>>
>>
>>
>> Tried out this option as well, seems to work, but to use it one must set
>> the Content-Type to “application/vnd.aerogear.v101+json” instead of the
>> Accept header.
>>
>>
>> _______________________________________________
>> aerogear-dev mailing list
>> aerogear-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/aerogear-dev
>>
>
> _______________________________________________
> aerogear-dev mailing list
> aerogear-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/aerogear-dev
>
>
>
> _______________________________________________
> aerogear-dev mailing list
> aerogear-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/aerogear-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/aerogear-dev/attachments/20140902/f889a74b/attachment.html 


More information about the aerogear-dev mailing list