【问题标题】:Swagger is adding additional body parameter for get methodSwagger 正在为 get 方法添加额外的 body 参数
【发布时间】:2018-07-17 02:50:04
【问题描述】:

我正在使用 swagger akka-http 包装器,目前对于我的 get 请求,swagger 正在在字符串类型的 swagger 规范中添加额外的 body 参数

@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”,有没有人有任何建议

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-23
      • 2012-11-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多