Configure JSONDoc controller

The only thing to do on your side is to declare the jsondoc controller in your spring context.xml file:

<beanid="documentationController"class="org.jsondoc.springmvc.controller.JSONDocController"><constructor-argname="version"value="1.0"/><constructor-argname="basePath"value="http://localhost:8080/api"/><constructor-argname="packages"><list><value>org.jsondoc.sample.controller</value><!-- packages in which you have your spring controllers --><value>org.jsondoc.sample.pojo</value><!-- packages in which you have your objects --><value>com.sample.external.pojo</value><!-- they can also belong to external jars --></list></constructor-arg><propertyname="playgroundEnabled"value="true"/><!-- optional --><propertyname="displayMethodAs"value="URI"/><!-- optional --></bean>

In this case the documentation will be generated at http://localhost:8080/api/jsondoc. You only have to specify the api version and the base path to give you readers a better information.

Change the base path of your web application, or better put a placeholder here and in the pom.xml and filter this file to have it replaced for free for different environments

In the packages list property you should put packages that contain spring controllers and objects needed for the documentation generation, as far as they are on the classpath. The scan is recursive.

See Configuration for more information about how to configure the JSONDoc controller.

Display the generated docs

With jsondoc-ui

You can include the jsondoc-ui project in your web application. This provides an interface to browse the generated documentation and a playground to test methods. It is built on Twitter Bootstrap and can be easily customized for you needs. To do this you need to get the jsondoc-ui jar, extract it and copy css, js, font, jsondoc-ui.html to your project's webapp folder. Check out the live demo here or the sample applications code. Here is the dependency to the jsondoc-ui: