-3

I have implemented Versionning as below. Currently I am Implementing it like this manner

@GET
@Path("/{id}")
@Produces("application/v1+json;version=1")
public TrackV1 getV1(@PathParam("id") int id) String version) {
    return new TrackV1("Version=1", "Version=1", "2:30", 1941);
}

@GET
@Path("/{id}")
@Produces("application/v2+json;version=2")
public TrackV1 getVa1(@PathParam("id") int id) {
    return new TrackV1("Version=2", "Version=2", "2:30", 2941);
}

But I need to change it into following Implementation :-

@GET
@Path("/{id}")
@Produces("application/json;version=1")
public TrackV1 getV1(@PathParam("id") int id) String version) {
    return new TrackV1("Version=1", "Version=1", "2:30", 1941);
}

@GET
@Path("/{id}")
@Produces("application/json;version=2")
public TrackV1 getVa1(@PathParam("id") int id) {
    return new TrackV1("Version=2", "Version=2", "2:30", 2941);
}

So any help how to implement in Spring or Jax-Rs and Jersey.

  • Please clarify your question. – cassiomolin Aug 10 '16 at 14:11
  • In @Produces Tag I have used ("application/versionId+json");But I need to change it to @Produces("application/json;version=id").So How to Change it?What I need to change? – Riddhik_debugger Aug 10 '16 at 16:09
  • 2
    Possible duplicate of [Easy REST resource versioning in JAX-RS based implementations?](http://stackoverflow.com/questions/4924034/easy-rest-resource-versioning-in-jax-rs-based-implementations) –  Aug 12 '16 at 17:29

1 Answers1

0

I found the solution to my Question :-

@GET
@Produces("application/xml;version=1")
public Response getAddonListVersion1(@Context UriInfo uriinfo) {
    logger.debug("START:Addons Dummy Service Implementation");

    return Response.ok("Version 1", "application/xml").build();
}

@GET
@Produces("application/xml;version=2")
public Response getAddonListVersion1(@Context UriInfo uriinfo) {
    logger.debug("START:Addons Dummy Service Implementation");

    return Response.ok("Version 2", "application/xml").build();
}

Using Jersey It is giving Problem but when you use apache-cxf ws implementation or use RestEasy you could easily have these type of versionning.