当您在swagger演示网站上查看时,他们有子路径
我正在使用swagger-spray碰巧使用官方swagger annotations。
当我构建我的api时,所有使用@Api注释的内容都会被分组为一个带有单个路径的api条目。
如何在此范围内设置多个子路径,例如“/ user / login”和“/ user / logout”?
答案 0 :(得分:2)
很简单
添加@javax.ws.rs.Path(“/ mysubpath”)
例如
@Api(value = "/auth", description = "Operations handling authentication")
trait AuthenticationApi {
val authenticationApiRouting: Route = {
loginRoute ~ logoutRoute
}
@ApiOperation(
value = "Ends current user session", notes = "Uses cookie",
nickname = "login",
httpMethod = "DELETE")
@ApiImplicitParams(Array(
new ApiImplicitParam(name = "email", value = "email of user to login", required = false, dataType = "string", paramType = "path")
))
@Path("/logout")
def logoutRoute = {
pathPrefix("auth") {
pathPrefix("logout") {
pathEndOrSingleSlash {
get {
complete {
<h1>test</h1>
}
}
}
}
}
}
然后你最终得到了这个