Swagger UI 和 Play routing *path
Swagger UI and Play routing *path
我在 Swagger 理解 Play 时遇到了问题! 2.0 路由通配符路由,所以 swagger ui 以损坏的 URL 结束。
我的路线文件有这条路线:
GET /settings/api/:project/*path @controllers.API.getParams(project, path)
然后我的控制器有如下代码:
@ApiOperation(value = "Returns settings for given project and path.", response = String.class, httpMethod = "GET")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Request completed successfully."),
@ApiResponse(code = 500, message = "Internal error while processing request")
})
@ApiImplicitParams({
@ApiImplicitParam(name = "project", value = "Project name", required = true, dataType = "String", paramType = "path"),
@ApiImplicitParam(name = "path", value = "path", required = true, dataType = "String", paramType = "path")
})
public Result getParams(String project, String path) {
return ok(path);
}
然后当 Swagger UI 被渲染时,我看到这个动作的路径被渲染为
POST /settings/api/{project}/{path<.+>
当我打电话时,它变成了
/settings/api/test/{path<.+>
所以基本上 :project 被替换了,但 *path 仍然存在 broken/intact。
如果您知道如何解决此问题,请分享。谢谢!
事实证明 swagger 不支持通配符路由。
我在 Swagger 理解 Play 时遇到了问题! 2.0 路由通配符路由,所以 swagger ui 以损坏的 URL 结束。 我的路线文件有这条路线:
GET /settings/api/:project/*path @controllers.API.getParams(project, path)
然后我的控制器有如下代码:
@ApiOperation(value = "Returns settings for given project and path.", response = String.class, httpMethod = "GET")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Request completed successfully."),
@ApiResponse(code = 500, message = "Internal error while processing request")
})
@ApiImplicitParams({
@ApiImplicitParam(name = "project", value = "Project name", required = true, dataType = "String", paramType = "path"),
@ApiImplicitParam(name = "path", value = "path", required = true, dataType = "String", paramType = "path")
})
public Result getParams(String project, String path) {
return ok(path);
}
然后当 Swagger UI 被渲染时,我看到这个动作的路径被渲染为
POST /settings/api/{project}/{path<.+>
当我打电话时,它变成了
/settings/api/test/{path<.+>
所以基本上 :project 被替换了,但 *path 仍然存在 broken/intact。 如果您知道如何解决此问题,请分享。谢谢!
事实证明 swagger 不支持通配符路由。