Live RESTful documentation with Spring Boot and Swagger
April 5, 2016
- Alfredo Díaz
As soon as you build an API including a few operations, you will realize that is hard to maintain code and documentation in sync. Therefore you can use a tool like Swagger. It can generate easly a high quality documentation for you.
Swagger is both a specification and a framework implementation. The strength of Swagger is its hability to keep in sync the code and the documentation. Once you integrate Swagger with your server app, it will generate a live RESTful documentation which will let you navigate and test without coding a single line.
How to integrate your Spring Boot Application with Swagger
First step: Enabling Swagger
Including this annotation in a configuration class
Second step: provide general api information
This is an example
Third step: include annotations in your api
There are a bunch of annotations that can be used but the most important are:
Marks a class as a Swagger resource
Describes an operation or typically a HTTP method against a specific path.
A list of multiple ApiResponses
Browsing the live api-doc
Enter this page