java - 是否有任何选项可以为 /swagger-ui 路径添加前缀?开放API
问题描述
你知道如何添加我的应用程序名称 /swagger-ui 作为前缀吗?喜欢
springdoc:
swagger-ui:
path: classpath:/META-INF/swagger-ui
但上面的代码根本不起作用。我想访问 localhost:8080/application-service/swagger-ui 而不是 localhost:8080/swagger-ui (这是通过 springdoc.swagger-ui.path=/swagger-ui 解决的
我不想使用:
server:
servlet:
context-path: /application-service
因为所有端点都有不同的路线。谢谢
解决方案
springdoc:
swagger-ui:
path: "application-service"
使用上述方法时,您将能够在以下位置访问 Swagger-UIhttp://localhost:8080/application-service
请注意,即使使用上述属性也会将您重定向到localhost:8080/swagger-ui
,但额外的好处是您将拥有不同的 URL 来访问 Swagger-UI。此外,到目前为止,路径中还没有 a /
,这意味着您不能有一个 n 级路径来公开 Swagger-UI(这在某种程度上是有道理的,因为 Swagger 是参考文档,应该很容易访问)。
推荐阅读
- angular - Angular - 如何使路由器出口指令忽略查询参数
- c - 在单独的函数中访问数组指针
- git - 有没有办法 git stash 文件的特定行?
- reactjs - auth0.webAuth.authorize() 需要哪些字段?
- javascript - HTML Textarea:如何在值更改时收到通知(未触发输入事件)
- flutter - ListView 中的提供者没有被处置?
- powershell - 来自 CSV 的 New-ADUser OtherAttributes var
- rust - 使用可变迭代器进行迭代时对不可变借用执行操作
- oracle - “选择进入”期间的 PL/SQL 错误“没有足够的值”
- twilio - 如何将回复重定向到我的常规电话号码?