Swagger Documentation with Spring Boot
๐ What is Swagger?
Swagger (OpenAPI) is a tool that automatically generates interactive API documentation for your REST endpoints โ making it easier to test, share, and understand your APIs.
๐ Quickstart: Swagger with Spring Boot
โ Step 1: Add Swagger Dependencies (OpenAPI 3)
In pom.xml
:
โ Step 2: Run Your App
Once the dependency is added and your Spring Boot app is running, visit:
or
Youโll see an interactive page listing all your REST endpoints! ๐
โ Step 3: Optional API Info (Customization)
You can customize the Swagger info using annotations:
๐ง๐ป Example REST Controller
These will appear automatically in Swagger UI.
๐ง Why Use Swagger?
- ๐ Auto-generated API documentation
- ๐งช Try out API endpoints directly from the browser
- ๐ค Easy to share with frontend/mobile teams
- โ Great for debugging and testing