如何为akka http web套接字路由生成swagger文档?

时间:2017-01-13 06:03:41

标签: scala swagger akka-http

如何为akka http Web套接字路由生成swagger文档?

我能写一个akka Http get,put,post,delete。例如

 @Path("/postPing")
 @ApiOperation(value = "Find a ping", notes = "Returns a pong",
 httpMethod = "POST",response = classOf[String])
 @ApiImplicitParams(Array(
 new ApiImplicitParam(name = "data", value = "\"data\" to sum",     required = true,
  dataType = "string", paramType = "query"),
new ApiImplicitParam(name = "file", required = true,
  dataType = "file", paramType = "query")
))
@ApiResponses(Array(
new ApiResponse(code = 404, message = "websocket not found"),
new ApiResponse(code = 200, message = "websocket found"),
new ApiResponse(code = 400, message = "Invalid websocket supplied")))
def postRoute = path("postPing") {
complete("post pong")
}

但我需要Akka网络套接字

def webSocketRoute: Route = path("websocket") {
handleWebSocketMessages(broadcast)
}
def broadcast: Flow[Message, Message, Any] = {
Flow[Message].mapConcat {
  case tm: TextMessage =>
    TextMessage(tm.textStream) :: Nil
 }
 }

例如  连接websocket服务器

/ connect ws://echo.websocket.org/websocket

将数据发送到websocket服务器

/发送Hello \ world

先谢谢

0 个答案:

没有答案