Swagger为get方法添加了额外的body参数

时间:2018-07-17 02:50:04

标签: swagger akka-http swagger-akka-http

我正在使用swagger akka-http包装器,目前,对于我的get请求,swagger正在在string类型的swagger规范中添加其他主体参数

@Path("/{id}/status")
  @ApiOperation(httpMethod = "GET", response = classOf[JobStatus], value = "Returns Job status")
  @ApiImplicitParams(Array(
      new ApiImplicitParam(name = "id", required = true, dataType = "integer", paramType = "path", value = "Job id for which status be fetched")))
  @ApiResponses(Array(
      new ApiResponse(code = 200, message = "OK", response = classOf[JobStatus]),
      new ApiResponse(code = 404, message = "Job not found")))
def getStatus(id: String): Route =
get {
....

我想知道这是因为getStatus方法采用参数“ id”,任何人都有建议吗

1 个答案:

答案 0 :(得分:0)

生成的文档基于函数参数和隐式参数(即2个参数集的并集)。 我建议您删除ApiImplicitParam批注,并在函数参数列表中的id字段中添加ApiModelProperty批注,如果您需要覆盖其声明的String类型。

使用ApiModelProperty注释的示例: https://github.com/pjfanning/swagger-akka-http-sample/blob/master/src/main/scala/com/example/akka/addoption/AddOptionActor.scala