How to Add OpenApi (Swagger) for Documenting a Spring REST API

Asep Saputra
Javarevisited
Published in
2 min readMay 24, 2021

--

In this post, I will show you how to add Swagger OpenAPI support to the Spring Boot project so that you can start documenting your REST API.

How to Add Swagger to Spring Boot

Preliminary

This post is a continuation of the previous article…

Steps

  • Add this to your pom.xml
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.5.2</version>
</dependency>

Next, build and run. You can access this to look the OpenAPI descriptions…

http://localhost:8080/v3/api-docs/

it will appear like this.

you can edit the path for the url by adding this to application.properties

springdoc.api-docs.path=/api

--

--