Hi everyone,
After chatting with Tony on IRC for a while, I've decided to take some of the questions offline so that they'll be available to everyone to view.
I'll try to split the questions into several topics so they won't clutter each other.
First thing's first - the API Listing.
Today, after a long time, I finally understood that besides the 'root' of the API Listing <host>/resources - all other resource listings are based on @Path annotations of the classes. Since the API Listing works with GET as well, if the top-level @Path has a @GET request, they'd conflict.
In order to resolve that, there's a nice solution of creating a helper class that holds the root path API listing, and it can be linked to via the root class.
While this is a useable solution, I feel that it can make code maintenance a bit of a pain, especially for a large API code base.
In our code base, we have roughly 40 REST API classes. If I'm not mistaken, most if not all have a GET operation on their roots.
Creating additional 40 helper classes seems like a huge overhead.
So in turn, I ask:
- Shouldn't the API listing use /resources as a base for all the listings? Conflicts can and will occur if the API listing is equivalent to the @Path usage. GET operations are especially common as well. Why not have a 'copy' of the REST calls under another level of hierarchy that's specifically used for the listing? I think that it should at least be configurable to be able to do that by default in order to help complex APIs.
- Another possible solution is to return the API listing response using the OPTIONS HTTP method. I'm no expert when it comes to REST and HTTP standards, but from what I can tell, OPTIONS is meant to be used for API listing in a way. I also doubt that many REST APIs out there use the OPTIONS call themselves - I imagine GET/POST/PUT/DELETE are far more common.
Thoughts?