Swagger / SpringFox Walkthrough
Swagger is an API framework that allows for interactive documentation, client SDK generation and discoverability. SpringFox is a SpringBoot application that sits on top of your api and allows you to explore it from your web browser.
Useful links
The petstore live demo
SpringFox reference Documentation
I used this guide to get myself up to speed.
My runnable implementation of the SpringFox demo
Demo Explaination
Essentially importing Swagger allows you to tag your REST API code with annotations like @ApiOperation and @ApiResponses. You can then annotate your main method with @EnableSwagger2 and create a bean using the Docket class provided by SpringFox. When you launch your SpringBoot app, the component scan will find your @RestController, and SpringFox will launch an API browser, using the annotations you added.
- The SpringFox UI used to browse your API
- http://localhost:8080/swagger-ui.html
- Paste /v2/api-docs?groups=greetings in the browse your endpoint
- Raw json describing your API from Swagger
- A list of your rest controllers and their associated documentation links
- In this example you can also hit the endpoint manually by visiting