Closed vickumar1981 closed 7 years ago
We are using swagger-play version 1.5.3 with Play 2.5.
swagger-play
1.5.3
Below are the relevant dependencies in the build.sbt:
build.sbt
libraryDependencies ++= Seq( ... "io.swagger" %% "swagger-play2" % "1.5.3", "org.webjars" %% "webjars-play" % "2.5.0-4", "org.webjars" % "swagger-ui" % "2.2.0" )
When I curl my endpoint to get a 400 error: `curl -vvv -X POST http://localhost:9000/users/login -H "X-Logon-Id: baduser" -H 'X-Password: badpassword'
I get this response:
< HTTP/1.1 400 Bad Request < errorCode: -66 < errorDesc: INVALID DATABASE USER < Content-Length: 66 < Content-Type: application/json < Date: Wed, 17 May 2017 14:49:50 GMT < * Connection #0 to host localhost left intact {"returnStatus":-66,"returnStatusMessage":"INVALID DATABASE USER"}
However, when I try the same thing in the swagger ui, I see neither the response headers nor the response body.
Below is the code from the controller:
@ApiOperation(value = "User login") @ApiImplicitParams(Array( new ApiImplicitParam(name = logonHeader, dataType = "java.lang.String", required = true, paramType = "header", value = ""), new ApiImplicitParam(name = pwHeader, dataType = "java.lang.String", required = true, paramType = "header", value = ""))) @ApiResponses(Array( new ApiResponse(code = 200, message = "Success", response = classOf[models.ApiResponse]), new ApiResponse(code = 400, message = "Error", response = classOf[models.ApiResponse]))) def loginUser() = Action { request => { val response = loginDAO.loginUser( request.headers.get(logonHeader).getOrElse(""), request.headers.get(pwHeader).getOrElse("")) if (response.returnStatus == 0) Ok(Json.toJson(response)) else Result( header = ResponseHeader(400, Map("errorCode" -> response.returnStatus.toString, "errorDesc" -> response.returnStatusMessage)), body = HttpEntity.Strict(ByteString(Json.toJson(response).toString()), Some("application/json")) ) }
I used Result instead of BadRequest b/c I wanted to set additional header information and see if that was the issue.
Result
BadRequest
I believe either I haven't done the annotations correctly, or this is possibly a bug in the swagger ui.
Sorry, turns out not to be an issue with play-swagger, but with swagger-ui newer versions.
We are using
swagger-play
version1.5.3
with Play 2.5.Below are the relevant dependencies in the
build.sbt
:When I curl my endpoint to get a 400 error: `curl -vvv -X POST http://localhost:9000/users/login -H "X-Logon-Id: baduser" -H 'X-Password: badpassword'
I get this response:
However, when I try the same thing in the swagger ui, I see neither the response headers nor the response body.
Below is the code from the controller:
I used
Result
instead ofBadRequest
b/c I wanted to set additional header information and see if that was the issue.I believe either I haven't done the annotations correctly, or this is possibly a bug in the swagger ui.