I had given up and went to use Spring Boot 2.7 after posting the question. But, after seeing Dmitriy's answer though, I checked Springdoc one last time and found that Springdoc v2 does support Spring Boot 3.

Essentially, one has to place the following in their pom:

<dependency>
   <groupId>org.springdoc</groupId>
   <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
   <version>2.0.0</version>
</dependency>

Then one can access the Swagger page using the following URL: http://localhost:8080/swagger-ui.html (Don't forget to add context path if you need it). For some reason, when opening, it redirects to http://localhost:8080/swagger-ui/index.html although going for that initially returned 404.

Answer from Ahmed Tawfik on Stack Overflow
🌐
Bell Software
bell-sw.com › blog › documenting-rest-api-with-swagger-in-spring-boot-3
How to use Swagger with Spring Boot
To work with Swagger, we need the springdoc-api library that helps to generate OpenAPI-compliant API documentation for Spring Boot projects. The library supports Swagger UI and other useful features such as OAuth2 and GraalVM Native Image.
Top answer
1 of 16
95

I had given up and went to use Spring Boot 2.7 after posting the question. But, after seeing Dmitriy's answer though, I checked Springdoc one last time and found that Springdoc v2 does support Spring Boot 3.

Essentially, one has to place the following in their pom:

<dependency>
   <groupId>org.springdoc</groupId>
   <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
   <version>2.0.0</version>
</dependency>

Then one can access the Swagger page using the following URL: http://localhost:8080/swagger-ui.html (Don't forget to add context path if you need it). For some reason, when opening, it redirects to http://localhost:8080/swagger-ui/index.html although going for that initially returned 404.

2 of 16
18

I agreed with @Ahmed Tawfik because I also faced the same. But today I tried that same approach with the new version of "springdoc-openapi-starter-webmvc-ui" dependency and Spring Boot 3.0.2-SNAPSHOT.

    <dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
      <version>2.0.2</version>
    </dependency>

because the previous one "springdoc-openapi-ui" is changed to the above one.

Also, include below the path to the security config for swagger UI.

"/v3/api-docs/**","/swagger-ui/**"

For my project,

@Bean
    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
        return http.cors(AbstractHttpConfigurer::disable)
                .csrf(AbstractHttpConfigurer::disable)
                .exceptionHandling(exceptionHandlingConfigurer -> exceptionHandlingConfigurer.authenticationEntryPoint(unauthorizedHandler))
                .authorizeHttpRequests(authorizationManagerRequestMatcherRegistry -> {
                            try {
                                authorizationManagerRequestMatcherRegistry
                                        .requestMatchers(HttpMethod.POST, POST_AUTH_WHITELIST).permitAll()
                                        .requestMatchers(HttpMethod.GET, GET_AUTH_WHITELIST).permitAll()
                                        .requestMatchers("/v3/api-docs/**", "/swagger-ui/**").permitAll()
                                        .anyRequest()
                                        .authenticated()
                                        .and()
                                        .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS));
                            } catch (Exception e) {
                                throw new ResourceNotFoundException(e.getMessage());
                            }
                        }
                )
                .formLogin(AbstractHttpConfigurer::disable)
                .httpBasic(AbstractHttpConfigurer::disable).addFilterBefore(jwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class)
                .authenticationProvider(daoAuthenticationProvider()).build();
    }

The swagger UI link will be:

http://server:port/context-path/swagger-ui.html

Please adjust the server, port, and context-path regarding your personal changes.

All the above steps are working fine with my project. I don't need extra configuration.

Also, you can add the custom path (Optional):

springdoc.swagger-ui.path=/swagger-ui.html

Here is the Official Documentation of OpenApi 3 and Spring Boot : https://springdoc.org/v2/#features

In the above documentation, you can explore additional configurations and other things also.

Happy Learning!

Discussions

How to specify api docs url for swagger ui in spring boot (open api v3)? - Stack Overflow
I have a spring boot application with open-api 3 that is deployed in Kubernetes (spring-boot-starter-parent 2.2.4.RELEASE). The rest endpoints are accessible through ingress, so URL is something like: ... I have the problem that as soon as the application is deployed to ingress, api-docs are available too via: ... When I open Swagger UI ... More on stackoverflow.com
🌐 stackoverflow.com
java - Customizing Springdocs/Swagger UI paths in Spring Boot 3 - Stack Overflow
6 Enabling Swagger springdoc-openapi-ui (OpenAPI 3.0) with Spring Security - Cannot access swagger-ui.html (401) 3 springdoc-openui swagger url default to petstore api and not disabling More on stackoverflow.com
🌐 stackoverflow.com
Unable to set up swagger with spring boot 3
You can check if the Swagger dependency was really added. I'm not sure why, but sometimes the IDE can fail to add some dependencies automatically. When that happens, I add another dependency or use Maven to add the dependency manually. http://localhost:8080/swagger-ui/index.html -> Show the pretty Swagger page http://localhost:8080/v3/api-docs -> Show some info in JSON style Swagger Jars More on reddit.com
🌐 r/SpringBoot
3
4
September 17, 2024
Swagger not working for Spring Boot 3
Can you provide some context. What kind of logs do you expect? Have you tried to add something simple like adding some swaggerannotations and see if the open api file is indeed generated and/or viewable in the ui ? More on reddit.com
🌐 r/SpringBoot
4
1
September 3, 2024
🌐
SpringDoc
springdoc.org
OpenAPI 3 Library for spring-boot
This will automatically deploy ... swagger-ui jars · The Swagger UI page will then be available at http://server:port/context-path/swagger-ui.html and the OpenAPI description will be available at the following url ...
🌐
Baeldung
baeldung.com › home › spring › spring security › spring boot 3 – configure spring security to allow swagger ui
Spring Boot 3 – Configure Spring Security to Allow Swagger UI | Baeldung
October 16, 2024 - The springdoc-openapi-starter-webmvc-ui is a Springdoc OpenAPI library that encapsulates Swagger. It contains the required dependencies and annotations to set up Swagger in the application. The spring-boot-starter-security dependency provides Spring Security for the application. When we add this dependency, Spring Security is enabled by default and blocks access to all URLs...
🌐
BezKoder
bezkoder.com › home › spring boot + swagger 3 example (with openapi 3)
Spring Boot + Swagger 3 example (with OpenAPI 3) - BezKoder
January 25, 2024 - implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.15' Run Spring Boot project. Open browser with url: http://localhost:8080/swagger-ui/index.html
Find elsewhere
🌐
Medium
apu-pradhan.medium.com › how-to-set-up-swagger-in-spring-boot-68b3fe862a0d
How to Set Up Swagger in Spring Boot | by Apu | Medium
November 18, 2024 - Ensure your SpringDoc version matches your Spring Boot version to avoid compatibility issues. Use the following guidelines: Spring Boot 2.6.x or 2.7.x: Use SpringDoc version 1.6.x. Spring Boot 3.x: Use SpringDoc version 2.x (e.g., ...
🌐
Springfox
springfox.github.io › springfox › docs › current
Springfox Reference Documentation
All content is served from a webjar convention, relative url taking the following form: webjars/springfox-swagger-ui/3.0.0/swagger-ui.html · By default Spring Boot has sensible defaults for serving content from webjars.
🌐
Baeldung
baeldung.com › home › spring › spring boot › change swagger-ui url prefix
Change Swagger-UI URL prefix - Spring Boot
May 11, 2024 - Learn how to change the Swagger-UI URL prefix when using Springfox and how to set up the REST API documentation using OpenAPI 3.0 with redirections.
🌐
SpringDoc
springdoc.org › faq.html
F.A.Q
The properties springdoc.swagger-ui.urls.*, are suitable to configure external (/v3/api-docs url). For example if you want to agreagte all the endpoints of other services, inside one single application. IMPORTANT: Don’t forget that CORS needs to be enabled as well.
🌐
Javainuse
javainuse.com › spring › boot_swagger3
Spring Boot + Swagger 3 (OpenAPI 3) Hello World Example
If we now go to localhost:8080/swagger-ui.html we can see the swagger ui as follows- Also if we go to http://localhost:8080/v3/api-docs, the OpenAPI description will be available at the following url for json format - If suppose we want to change the title and other properties for swagger.
🌐
DEV Community
dev.to › mspilari › integrating-swagger-with-spring-boot-3-2ho8
Integrating Swagger with Spring Boot 3 - DEV Community
March 10, 2025 - With Spring Boot 3, we can easily integrate Swagger using the OpenAPI specification. This tutorial will guide you through setting up Swagger in a Spring Boot 3 application and documenting a user management API. Spring Boot 3 supports OpenAPI through the springdoc-openapi-starter-webmvc-ui dependency.
🌐
Baeldung
baeldung.com › home › rest › documenting a spring rest api using openapi 3.0
Documenting a Spring REST API Using OpenAPI 3.0 | Baeldung
March 26, 2026 - The springdoc.swagger-ui.url property overrides the default location where Swagger UI fetches the OpenAPI specification.
🌐
GitHub
github.com › pasan1 › Spring-Boot-3-with-spring-security-and-swagger-ui
GitHub - pasan1/Spring-Boot-3-with-spring-security-and-swagger-ui: Spring Boot 3 project with Spring Security and Swagger UI integrated (with OpenAPI 3) · GitHub
This project is a Spring Boot 3 web application that integrates Spring Security for authentication and authorization, and Swagger UI for API documentation using OpenAPI 3.
Starred by 9 users
Forked by 12 users
Languages   Java
🌐
Reddit
reddit.com › r/springboot › unable to set up swagger with spring boot 3
r/SpringBoot on Reddit: Unable to set up swagger with spring boot 3
September 17, 2024 -

I am trying to setup swagger with spring boot.

Here is my java version:

> java --version
openjdk 23 2024-09-17
OpenJDK Runtime Environment (build 23+37-2369)
OpenJDK 64-Bit Server VM (build 23+37-2369, mixed mode, sharing)

Here is my pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mahesha999</groupId>
  <artifactId>spring-boot-postgres</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <parent>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-starter-parent</artifactId>
     <version>3.2.0</version>
     <relativePath/>
  </parent>

  <properties>
    <java.version>23</java.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-devtools</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
      <version>2.6.0</version>
    </dependency>
  </dependencies>
</project>

When I hit following URLs:

localhost:8080/swagger-ui/index.html
localhost:8080/swagger-ui.html
localhost:8080/swagger-ui/
localhost:8080/v3/api-docs

I get whitelabel error page, something like this:

I tried some other swagger dependencies available online with no luck. How can I make swagger UI work with my java and spring boot version? Or do I need to change my java and / or spring boot verions themselves? Do I need to specify context-path as specified here?

🌐
TheServerSide
theserverside.com › video › OpenAPI-Swagger-and-Spring-Boot-REST-APIs
OpenAPI, Swagger and Spring Boot REST APIs | TheServerSide
To add the OpenAPI 3.0-compliant ... Swagger-enabled Spring Boot REST application. Access the Spring Boot Swagger UI at the following URL: http://localhost:8080/swagger-ui...