➤ How to Code a Game
➤ Array Programs in Java
➤ Java Inline Thread Creation
➤ Java Custom Exception
➤ Hibernate vs JDBC
➤ Object Relational Mapping
➤ Check Oracle DB Size
➤ Check Oracle DB Version
➤ Generation of Computers
➤ XML Pros & Cons
➤ Git Analytics & Its Uses
➤ Top Skills for Cloud Professional
➤ How to Hire Best Candidates
➤ Scrum Master Roles & Work
➤ CyberSecurity in Python
➤ Protect from Cyber-Attack
➤ Solve App Development Challenges
➤ Top Chrome Extensions for Twitch Users
➤ Mistakes That Can Ruin Your Test Metric Program
Swagger with Spring Boot REST | POSTMAN Tool tests our rest controllers. This is a fully manual tool, we should enter all details: URL, MethodType, Param, JSON Input, Header Details, etc.
We should list all URLs in the application, if it is a small application then it is fine. But if the application is big (having 40 controllers with multiple methods like save, update, delete, get, etc) in this case checking all URLs, types, and Input is a bit complex and time-consuming process.
Swagger is an advanced test tool compared to POSTMAN. It provides an easy UI for testing all RestControllers in the project.
If we use Swagger, we do need not to enter the URL, and choose Method Type manually. We need to enter only input data.
Swagger Configuration in Spring Boot REST
Step-1:- Define one Spring Boot project with RestControllers
Step-2:- Add the springdoc-openapi-starter-webmvc-ui
dependencies
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.3.0</version>
</dependency>
See more:- Why not to use springfox-swagger2, and springfox-swagger-ui dependecies
We don’t need to add any configuration, no need to create the Docket, and no need to give the rest controller package path.
The Swagger UI page will then be available at:- http://localhost:8080/swagger-ui/index.html
![Swagger with Spring Boot REST 1 Swagger UI](https://www.knowprogram.com/wp-content/uploads/2024/06/Swagger-UI-1024x503.webp)
Swagger is not for adding any functionalities, it works only to make testing easy.
![Swagger with Spring Boot REST 2 Swagger UI Sample](https://www.knowprogram.com/wp-content/uploads/2024/06/Swagger-UI-Sample-1024x618.webp)
If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!