玩 Swagger UI url 别名
Play Swagger UI url alias
我有 Swagger UI
用于 API 文档,我使用与 official specification 中相同的方法来访问它 我接下来使用 URL:
http://localhost:9000/docs/swagger-ui/index.html?url=/assets/swagger.json
但我想改用 http://localhost:9000/docs/
。我不想使用 WS
进行委派,我想在 routes
中使用单行,如下所示:
GET /docs controllers.Assets.at(path:String="/public/lib/swagger-ui", file:String="index.html?url=/assets/swagger.json")
或
GET /docs controllers.Assets.at(path:String="/public/lib/swagger-ui", file:String="index.html")
和http://localhost:9000/docs?url=/assets/swagger.json
我应该改变什么才能让它起作用?
没有Play-Swagger如何解决:
- 在您的项目中创建目录 public\swagger;
- 从 https://github.com/swagger-api/swagger-ui/tree/master/dist 下载所有文件并将它们复制到 public\swagger;
- 将您的 swagger.json(这是规范,对吧?)复制到 public\specification;
- 添加到您的 routes 文件下一行:
GET /docs
controllers.Assets.versioned(path="/public/specification", file: Asset
= "swagger.json")
您不能在 URL /docs/swagger-ui/index.html?url=/assets/swagger.json
的路由文件中缩短,因为 index.html
是由 swagger-ui plugin
生成到 public
目录并且请求 uires 访问附近的文件(如 js 和 css 文件)。 Play swagger-ui
使用 javascript
通过 URL 参数获取基于 json
的路线描述,以进一步将此文档解析为 swagger-ui,在您的情况下它是 /assets/swagger.json
端点。
我试图制作 mapping swagger 的 index.html
文件,所以直接像 URL parameter
一样传递 json
位置:
GET /swagger-ui controllers.Assets.at(path = "/public/lib/swagger-ui", file = "index.html")
Play 无法呈现此页面,CSS 未找到。我将虚拟映射附加到 swagger 默认目录 /public/lib/swagger-ui
:
中的每个文件
GET /*file controllers.Assets.at(path = "/public/lib/swagger-ui", file)
即使在那之后 Play 也无法正确呈现 index.html
。
我有 Swagger UI
用于 API 文档,我使用与 official specification 中相同的方法来访问它 我接下来使用 URL:
http://localhost:9000/docs/swagger-ui/index.html?url=/assets/swagger.json
但我想改用 http://localhost:9000/docs/
。我不想使用 WS
进行委派,我想在 routes
中使用单行,如下所示:
GET /docs controllers.Assets.at(path:String="/public/lib/swagger-ui", file:String="index.html?url=/assets/swagger.json")
或
GET /docs controllers.Assets.at(path:String="/public/lib/swagger-ui", file:String="index.html")
和http://localhost:9000/docs?url=/assets/swagger.json
我应该改变什么才能让它起作用?
没有Play-Swagger如何解决:
- 在您的项目中创建目录 public\swagger;
- 从 https://github.com/swagger-api/swagger-ui/tree/master/dist 下载所有文件并将它们复制到 public\swagger;
- 将您的 swagger.json(这是规范,对吧?)复制到 public\specification;
- 添加到您的 routes 文件下一行:
GET /docs
controllers.Assets.versioned(path="/public/specification", file: Asset = "swagger.json")
您不能在 URL /docs/swagger-ui/index.html?url=/assets/swagger.json
的路由文件中缩短,因为 index.html
是由 swagger-ui plugin
生成到 public
目录并且请求 uires 访问附近的文件(如 js 和 css 文件)。 Play swagger-ui
使用 javascript
通过 URL 参数获取基于 json
的路线描述,以进一步将此文档解析为 swagger-ui,在您的情况下它是 /assets/swagger.json
端点。
我试图制作 mapping swagger 的 index.html
文件,所以直接像 URL parameter
一样传递 json
位置:
GET /swagger-ui controllers.Assets.at(path = "/public/lib/swagger-ui", file = "index.html")
Play 无法呈现此页面,CSS 未找到。我将虚拟映射附加到 swagger 默认目录 /public/lib/swagger-ui
:
GET /*file controllers.Assets.at(path = "/public/lib/swagger-ui", file)
即使在那之后 Play 也无法正确呈现 index.html
。