views:

35

answers:

3

hi, We've been using Jersey for our webservice and it's been great and straightforward. Is there a way to add a small description comment within a method definition (maybe using an annotation like @Description):

@GET
@Path("/schema/classes/")
@Produces( { APPLICATION_RDF, TEXT_N3, APPLICATION_JSON })
@Description("Lists all ontology classes")
public Response getClasses() throws JobOntoException {
  ...
}

And in the WADL that would give something like:

<application>
 <doc jersey:generatedBy="Jersey: 1.1.5 01/20/2010 03:55 PM"/>
  <resources base="http://localhost:9998/"&gt;
   <resource path="/jobonto">
    <resource path="/schema/classes/">
     <method name="GET" id="getClasses">
      **<description>"Lists all ontology classes"</description>**
      <response> 
       <representation mediaType="application/rdf+xml"/>
       <representation mediaType="text/rdf+n3"/>
       <representation mediaType="application/json"/>
      </response>
     </method>
    </resource>
    ...

Thanks, Renaud

A: 

Here is an even better idea. Put the description in the representation that you use to link to this resource.

What media type are you using for the representation at the root of your service? Xhtml can be very useful for this because it is easy to parse, has existing support for links and renders nicely in a browser.

Darrel Miller
We use json, and rdf or n3. I am actually more interested in describing what the service method is doing, rather than how the representations are structured.
Renaud
A: 

Renaud,

are you using the WADL to provide a service description to the client developer?

If so, please not that this is not RESTful as it violates the hypermedia constraint. WADL expresses information that a client developer must not rely on. WADL essentially contains information about available transitions and the hypermedia constraint requires such information to be discovered at runtime, not to be known at design time.

Thus, using WADL ad runtime in the sense of a form is fine[1] because you can change the WADL without breaking any clients.

[1] Though the style is debatable - personally, I would rather design domain specific media types

Jan

Jan Algermissen
Thanks Jan,Yes, we would like to use the WADL (which is generated on the fly by Jersey) as a kind of mini-spec / description for the client dev.I understand that in theory WADL are not supposed to be used like this. But for our project it will be a good enough documentation for the clients/consumers. These will not dynamically/at runtime discover the service, and the service methods will likely not change very often.
Renaud
Yes, you can benefits from HTTP in terms of simplicity and visibility. I just have recently begun to point people more towards what is and what is not RESTful. So sorry you were kind of in the line of fire :-)Jan
Jan Algermissen
+2  A: 

You should try extending the WadlGeneratorConfig.

antonj