Add Swagger in Microservices

1. Swagger

Swagger is a set of open-source tools built around the OpenAPI Specification that can help you design, build, document and consume REST APIs, including

2. For adding Swagger UI into your spring boot application, you need to add these dependencies in pom.xml

3. Add @EnableSwagger2 annotation on top of your main class, and add @RequestMapping(“/api”) to your controller classess.

4. For Swagger UI configuration, you need to add this code in your main class.

5. Add the below line in application.properties file.

6. Swagger URL

Localhost:8080/swagger-ui.html

7. Source Code

Project Structure

img not found

pom.xml

Main class

Controller class

Bean class