-1

I have migrated to Spring Boot version 3 from 2.7 and Swagger UI stopped working.

Below are the dependencies I have used:

spring-boot-starter-parent - 3.0.0
springfox-boot-starter-3.0.0
springdoc-openapi-starter-webmvc-ui - 2.0.2
springdoc-openapi-core - 1.1.49

I have configured the following property in application.properties:

springdoc.api-docs.path=/api-docs

but I am still getting 403 error while opening Swagger UI in the bowser (http://localhost:8080/swagger-ui/index.html):

websecurityconfig class made the Swagger UI URL as public with the following code:

String[] PUBLIC_URL = {"/v3/api-docs",
            "/v2/api-docs", "/swagger-resources/**",
            "/swagger-ui/**",
            "/swagger-ui.html",
            "/v3/api-docs/**",
            "/api-docs/**",
            "api-docs" }
http.authorizeHttpRequests().requestMatchers(PUBLIC_URL).permitAll();
Helen
  • 87,344
  • 17
  • 243
  • 314
Umesh Goti
  • 39
  • 5
  • 1
    Springfox and Springdoc are incompatible. You probably need to remove "springfox-boot-starter-3.0.0" or maybe replace it with an equivalent Springdoc lib. – Helen Mar 02 '23 at 10:40
  • Please check my answer on **[How to run Swagger 3 on Spring Boot 3](https://stackoverflow.com/questions/74614369/how-to-run-swagger-3-on-spring-boot-3)** – Murat Yıldız Mar 18 '23 at 08:56

1 Answers1

0

Both springdoc-openapi-starter-webmvc-ui and springdoc-openapi-starter-webmvc-api are required in the classpath for Swagger to work in Spring boot 3 (Web Starter). Probably you might need to remove springdoc-openapi-core - 1.1.49. Also not sure if springfox will cause any trouble.

<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
    <version>2.0.2</version>
</dependency>
<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
    <version>2.0.2</version>
</dependency>
Coder
  • 6,948
  • 13
  • 56
  • 86