Skip to content
Ryan Heaton edited this page Sep 17, 2015 · 1 revision

Leveraging Enunciate Without JAX-*S

Let's say you'd love to use Enunciate's documentation features and you've got a REST API, but you're not using JAX-RS. You've got a couple of options.

Option 1: Create some interfaces without an implementation

One thing you could do is just create some interfaces that define your API in terms of JAX-RS, but don't supply an associated implementation class. Enunciate will pick up on your interfaces and generate the associated documentation.

Option 2: Apply "hints" to your existing code

The problem with option 1 is that you have to maintain the metadata in a separate place from where you maintain your API. There is a higher probability that the documentation will be out-of-sync.

The second option is that you can supply Enunciate with the necessary JAX-RS metadata using the @com.webcohesion.enunciate.metadata.rs.ResourceMethodSignature annotation. Here's an example of how you might use this annotation:

@Path("/myresource")
public class MyNonJaxrsResourceClass {

  @GET
  @ResourceMethodSignature (
    output = SomeResource.class,
    queryParams = {@QueryParam("param1"), @QueryParam("param2")}
  )
  public void handleGetSomeResource(HttpServletRequest request, HttpServletResponse response) {
    ...
  }

}
Clone this wiki locally