Skip to end of metadata
Go to start of metadata

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 @org.codehaus.enunciate.contract.jaxrs.ResourceMethodSignature annotation. Here's an example of how you might use this annotation:

  • No labels

1 Comment

  1. Hi Ryan,

    Could you do me a favor? I am meeting an exception below during invoking enunciate in ant. I don't know where is wrong. Can you point it out? Thanks so much.

    Dylan

    @GET
    @Path("/{recordIds}/fees/")
    @Produces(MediaType.APPLICATION_JSON)
    @ResourceMethodSignature(output = F4FeeModel.class, pathParams = {@PathParam("recordIds")}, queryParams = {@QueryParam("fields")})
    public ResponseModel getFeeItemsByCapID(@PathParam("recordIds") String recordIds,
    @QueryParam("fields") String fields) throws Exception

     

    Exception:

    java.lang.IllegalStateException: D:\AA7.2.0\main-dev\biz\modules\rest-apis\java\com\accela\restapis\jaxrs\agency\service\FeeWebService.java:79: the el
    ement 'value' must have a value specified.
    at net.sf.jelly.apt.decorations.declaration.DecoratedAnnotationMirror.<init>(DecoratedAnnotationMirror.java:66)
    at net.sf.jelly.apt.decorations.DeclarationDecorator.decorate(DeclarationDecorator.java:362)
    at net.sf.jelly.apt.decorations.DeclarationDecorator.decorateAnnotationMirrors(DeclarationDecorator.java:113)
    at net.sf.jelly.apt.decorations.declaration.DecoratedDeclaration.getAnnotationMirrors(DecoratedDeclaration.java:213)
    at net.sf.jelly.apt.decorations.declaration.DecoratedDeclaration.getAnnotations(DecoratedDeclaration.java:195)
    at net.sf.jelly.apt.decorations.declaration.DecoratedDeclaration.getAnnotation(DecoratedDeclaration.java:225)
    at org.codehaus.enunciate.contract.jaxrs.ResourceParameter.<init>(ResourceParameter.java:71)
    at org.codehaus.enunciate.contract.jaxrs.ExplicitResourceParameter.<init>(ExplicitResourceParameter.java:16)
    at org.codehaus.enunciate.contract.jaxrs.ResourceMethod.loadResourceParameters(ResourceMethod.java:348)
    at org.codehaus.enunciate.contract.jaxrs.ResourceMethod.<init>(ResourceMethod.java:190)
    at org.codehaus.enunciate.contract.jaxrs.Resource.getResourceMethods(Resource.java:143)
    at org.codehaus.enunciate.contract.jaxrs.Resource.<init>(Resource.java:69)
    at org.codehaus.enunciate.contract.jaxrs.RootResource.<init>(RootResource.java:34)
    at org.codehaus.enunciate.apt.EnunciateAnnotationProcessor.getRootModel(EnunciateAnnotationProcessor.java:214)
    at org.codehaus.enunciate.apt.EnunciateAnnotationProcessor.process(EnunciateAnnotationProcessor.java:103)