Question

I am looking for tools to generate documentation and client code (in various languages such as Java, Scala, Ruby, JavaScript, etc.) using annotation on my JAX-RS REST service. Ideally, I'd like to run a post-build tool that, given the package where my REST service classes live, will generate both documentation and code using (custom) annotation on the source code and some minimal configuration. Kind of what Swagger does but without having to deploy its servlet and all that stuff. I tried bending swagger-codegen to do this with no luck. The documentation is small and fragmented and the examples are few. I can't imagine this isn't a solved problem. Ideas?

Was it helpful?

Solution 3

I found out that this can (painfully) be achieved using Swagger to generate the Swagger endpoint specification from annotated JAX-RS endpoint classes and then using Swagger-Codegen to generate the client code. Unfortunately the two projects aren't binary compatible so they must be used separately, i.e., from two different modules, but beyond that, it's not too difficult to follow the examples and obtain the desired result.

OTHER TIPS

If you're using Jersey then it will automatically generate WADL from your JAX-RS services. You can then use wadl2java to create client stubs.

You can use CXF to generate client code from your annotated server side code. See http://blog.rjsang.com/2014/01/using-cxf-as-jax-rs-server-and-client.html.

In the example CXF is both the server and client but it doesn't have to be as long as you are using JAX-RS standard annotations.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top