Swagger is widely used for visualizing APIs, and with Swagger UI it provides online sandbox for frontend developers.
Swagger is a tool, a specification and a complete framework implementation for producing the visual representation of RESTful Web Services.
It enables documentation to be updated at the same pace as the server.
Pros :
- No need to maintain any separate document for API's.
- Once we update the API's in services it will reflect in Swagger UI.
Cons :
Swagger Implementation :
Step 1 : Add the below swagger dependencies (Latest versions) in pom.xml.
Step 2 : Write a swagger configuration class to configure the swagger UI.
- To enable the swagger UI we will use @EnableSwagger2 Annotation.
- Docket is used to get ApiInfoBuilder which provides the way to control the endpoints in swagger.
Step 3 : Write a controller with a Method GET.
Step 4 : Write a Spring boot main method to run the application.
Step 5 : Run the Swagger UI with below url
No comments:
Post a Comment