spring-bootgradlemigrationswagger-uiswagger-2.0

Spring Boot 3, springdoc-openapi-starter-webmvc-ui loads only sample data


I have a Java/Spring boot application using gradle that I recently upgraded from jdk8 to jdk17, and I upgraded spring boot from 2 to 3.1.4. The app has no problems with the upgrade, but the previous swagger UI no longer works. The previous dependency I used in gradle was:

implementation 'org.springdoc:springdoc-openapi-ui:1.6.6'

The previous URL to access swagger was:

www.example.com/api-app/swagger-ui/index.html?configUrl=/api-app/v3/api-docs/swagger-config

And swagger automatically picked up my rest controllers that were defined using Tag annotation like so:

@Tag(name = "Rest Controller Name", description = "Description of rest controller functionality.")

I see that upgrading to spring boot v3, that the dependency changed to:

implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'

And after applying this dependency change the swagger UI loads properly, but the only data available is the sample "Swagger Petstore" and my previous Tag annotations are not being read properly...

I updated my app.yml file to the newest swagger properties:

springdoc:
  swagger-ui:
    enabled: true
    config-url: /api-app/v3/api-docs/swagger-config    #(Same as previous query string url)

I attempted to disable the sample using springdoc.swagger-ui.disable-swagger-default-url: true but then the swagger ui is just blank and Tags are still not read.

I thought swagger was as simple as adding the dependency, but seems like my app is not being read properly even with the new swagger v2 with spring boot 3. I followed the migrating from v1 guide here: https://springdoc.org/#migrating-from-springdoc-v1

I have tried many other stack overflow suggestions but none of them are working for me. Any help as to what I'm missing or to read my Tag annotations correctly would be greatly appreciated.

I tried migrating "org.springdoc:springdoc-openapi-ui" to "org.springdoc:springdoc-openapi-starter-webmvc-ui" with spring boot 3 but none of my @Tag annotations are loading properly.


Solution

  • I got it working this morning, I have a security filter in place that permits all access to "/swagger-ui/index.html", but the "/v3/api-docs" url was getting blocked when trying to access.

    I permitted the /v3/ url all access and the JSON started returning properly, and the swagger UI started working after that.

    So for any future readers, make sure both URLs are allowed through your security filter.