[英]How to add context path in the swagger ui / open api in try it out
我正在使用 springdoc-openapi-ui 來記錄我的 REST 端點。
下面是pom依賴
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.9</version>
</dependency>
下面是我的 swagger url
http://localhost:40001/test/swagger-ui/index.html
swagger UI 打開得很好。 當我 go 控制器之一並單擊“試用”並執行 rest 端點時,我收到 404 錯誤。
當我檢查請求 url 它是
http://localhost:40001/my-service/v1/topic/123
我希望請求 url 是 http://localhost:40001/test/my-service/v1/topic/123 而不是上面的請求。
“試用”缺少上下文路徑“測試”
我在 application.properties 中指定了以下屬性
server.servlet.context-path=/test
“試用”沒有將上下文路徑“測試”添加到其請求 url。
我找到了解決方案。 我的配置文件中有以下注釋
@OpenAPIDefinition(servers = {@Server(url = "/", description = "默認服務器 URL")})
導致上下文路徑默認為 / 的原因。 刪除上面的注釋解決了這個問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.