Swagger - Integration with Spring Boot
- Swagger can we configure in two ways with Spring Boot
Simple JSON format and HTML UI look.
- Basically it will give all the endpoint (internal as well newly
created by you) shown by Swagger
- It is very helpfull for developer as well in Microservices env,
due to this we can quickly find the endpoints. Also less
documentation and interaction required.
JSON documentation -
- Add the dependency i.e. 'springfox-swagger2' for JSON
- Enable Swagger in your code. In your main class add annotation
@EnableSwagger2. Restart the application.
- Configuring Swagger
- Add additional details if required
- url will be 'http://localhost:8080/v2/api-docs' for JSON
HTML documentation -
- Add the dependency i.e. 'springfox-swagger-ui' for HTML
- Add @RequestMapping("/api"), some time not necessary to add this
requestmapping but if not reflecting then you need to add this.
- URL will be 'http://localhost:8080/swagger-ui.html' for JSON
- It is not just a Spring API also spring mvc can cover the API. It
will add spring default end-points etc.
- You also configure most of the section such as Application, on
particular end-point should be consider etc. More details
please refer this project