Documenting ReST webservices with Swagger
Documenting ReST webservice is a must and it is also tedius task. With every minor change in the api, documentation becomes to difficult to track. With Springfox-swagger, it takes a the documentation to a breeze with dynamic documentaion. Here is a quick look on how to document rest api dynamically.
Dependencies
The following maven dependencies are to be added.
<properties>
<spring-fox.version>2.3.1</spring-fox.version>
</properties>
<!-- Springfox swagger -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${spring-fox.version}</version>
</dependency>
<!-- Webjar UI -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${spring-fox.version}</version>
</dependency>
Configuration Class
The following configuration class in spring configuration is used to configure the springfox. More for information, refer springfox documentaion
Add Resource Handler
Spring class to handle resource via configuration to expose the resources of the webjar.
The access url should be at `http://server:port/context-root/swagger-ui.html`
For the full project reference visit redis-device-oui