Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JAX-RS Compatibility #671

Closed
nobeh opened this issue Dec 4, 2014 · 4 comments
Closed

JAX-RS Compatibility #671

nobeh opened this issue Dec 4, 2014 · 4 comments

Comments

@nobeh
Copy link

nobeh commented Dec 4, 2014

I understand that one focus of this nice library is aimed at Android.

I am interested to know what where the design decisions/concerns to have

@GET("/api/users/{id}"
public User getUser(@Path("id") String id);

rather than having JAX-RS spec API and then:

@GET
@Path("/api/users/{id}")
public User getUser(@PathParam("id") String id);

Thanks. And, any plans to support the spec?

@JakeWharton
Copy link
Collaborator

Retrofit is focused solely on the client-side and the annotations are customized for such. See #573 for more.

And, any plans to support the spec?

Unless a very, very compelling argument can be made (and I haven't seen one yet), no.

@JakeWharton
Copy link
Collaborator

Retrofit is also 4+ years old so it pre-dates JAX-RS 2 (which has better annotations than JAX-RS 1 for clients) by some time.

@nobeh
Copy link
Author

nobeh commented Dec 9, 2014

Thanks for the explanations. I do not intend to make an argument here but I have to say, in my opinion, what distinguishes Retrofit from others is that it allows to share/reuse unified interface signatures across different layers; i.e. define an interface in a one place, use it in a "backend" layer (of course with a different supporting library) and again use it again in a "presentation" layer.

@JakeWharton
Copy link
Collaborator

With 2.0 we're going to move even farther away from the ability to share making this impossible. I admire your desire to do this. I spent a good two days evaluating compatibility back in 2012 but deemed it impossible then and as we are focusing even more on client-specific behavior with 2.0 I simply don't think we can ever really do this.

What I would recommend doing is using an alternative format for representing your API endpoints and generating both the Retrofit service interface and the JAX-RS one for server side.

For example, we use protocol buffers:

service FooService {
  // @url /bar
  // @method POST
  rpc BarResponse bar(BarRequest);
  // @url /baz
  // @method POST
  rpc BazResponse baz(BazRequest);

which generate types and becomes:

interface FooService {
  @POST("/bar")
  BarResponse bar(BarRequest body);

  @POST("/baz")
  BazResponse baz(BazRequest body);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants