Is there a way to auto-generate a ZOHO-style documentation of my Jersey Rest Services? This is one of the best REST documentations I have seen so far. I'm open to alternatives.
Swagger also looks promising but I don't see how to generate it. It seems like it needs a YAML style documentation.
Can I generate it from javadoc somehow?
I'd prefer to generate the docs via Maven.
You can use Swagger to document your REST API, it's not difficult to set up. There are some instructions here. To summarize:
Adding Swagger dependencies
Add the following dependency to your
pom.xml
:Setting up Swagger
Add the following to your
Application
class (change the values according to your needs):Build your project, start your server and access
http://localhost:8080/app/api/swagger.json
(the URL might be different in your environment) to get the JSON which documents your API.Setting up Swagger UI
Download Swagger UI from GitHub and copy the content from the
dist
folder to your web content folder. I usually create a folder calledapi-docs
to store all Swagger UI files.Open Swagger UI's
index.html
and change the URL which refers to theswagger.json
:Access
http://localhost:8080/app/api-docs
(the URL might be different in your environment). The Swagger UI with your API documentation should be there.More information
You always can customize Swagger UI to fit your needs.
Swagger reads JAX-RS annotations to generate the documentation. Additionally, you can use Swagger annotations to improve it.
You can generate swagger-ui from Javadoc by using Enunciate, which has a Swagger module. First, you need to add the maven plugin to your pom file; e.g.
where 'enunciate.xml' contains your project specific configurations and looks like this:
Then run
mvn package
and it will generate Swagger documentation files from your Javadoc.p.s. taken from my answer here.
Adding swagger to jersey based services is not too complicated. See these detailed steps on how to go about it:
Hope that helps