Thursday, 8 July 2021

Configure/ Enable Swagger API for Spring Boot 2 (2.5.2)

 Enabling Swagger API documentation in Spring Boot 2.5.2 is pretty simple now.

We just need to few dependency and we are good to go

For Spring Boot Applications, If you are migrating to 2.5.2 version then perform the following operations

1. Remove library inclusions of earlier releases. Specifically remove springfox-swagger2 and springfox-swagger-ui inclusions.

2. Remove the @EnableSwagger2 annotations

3. Add the springfox-boot-starter as shown below

4. No need to external config class to configure docket-api. It is handled automatically.


Following is the dependency we have to add in our pom.xml (for maven project)


That's it!!!

and swagger-ui location has moved from 
http://host/context-path/swagger-ui.html 
to 
http://host/context-path/swagger-ui/index.html 
OR http://host/context-path/swagger-ui/

as shown below




The complete code can be found in my github

No comments:

Post a Comment