Swagger
What is Swagger?
Swagger is a tool that can be used to document APIs
. It can be used to generate documentation for APIs. Swagger can also be used to test api endpoints on the swagger UI.
How to use Swagger in Spring Boot?
To use swagger:
-
Add dependency to the pom.xml file.
- Add annotation to the entrance of the application.
@EnableSwagger
- Add annotation to the controller class.
@Api(value = "Controller Name", description = "Description of the controller")
-
Add the following annotation to the method of the controller class.
1.@ApiOperation(value = "Description of the method", response = Response.class)
2.@ApiResponses()
3.@ApiParam()
- Run the application and go to http://localhost:8080/swagger-ui.html