Search code examples
swaggerakka-httpswagger-akka-http

Swagger is adding additional body parameter for get method


I'm using swagger akka-http wrapper, Currently for my get request swagger is adding additional body parameter in swagger spec of type string

@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 {
....

I'm wondering this is because of getStatus method taking parameter "id", Do any one have any suggestion


Solution

  • The generated docs are based on the both the function parameters and the implicit parameters (ie the union of the 2 parameter sets). I would suggest that you remove the ApiImplicitParam annotation and add an ApiModelProperty annotation to the id field in the function parameter list if you need to override its declared type of String.

    Example use of ApiModelProperty annotation: https://github.com/pjfanning/swagger-akka-http-sample/blob/master/src/main/scala/com/example/akka/addoption/AddOptionActor.scala