I've a spring boot application (2.5.6) with a dependency on springdoc-openapi. However, launching swagger-ui (http://localhost:8080/v1/swagger-ui/index.html) doesn't work. The debug logs are indicating that index.html is not present. What could be the reason that index.html is not found ?
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.8</version>
</dependency>
application.yaml
springdoc:
swagger-ui:
tagsSorter: alpha
operations-sorter: alpha
doc-expansion: none
disable-swagger-default-url: true
logging:
level:
root: DEBUG
server:
port: 8080
spring:
application:
name: fe-applic-app
api-version: "v1"
Try swagger-ui.html
instead of swagger-ui/index.html
. In 60% of the cases swagger-ui.html
redirects to its real location.
http://localhost:8080/v1/swagger-ui.html http://localhost:8080/v3/swagger-ui.html
I found the cause of the problem. The context-path was not set in application.yaml.
http://localhost:8080/ v1 /swagger-ui/index.html
After adding servlet : context-path , swagger-ui is rendered
server:
port: 8080
servlet:
context-path: "/${spring.application.api-version}"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.