Hi!
I'm currently exercising my REST API with the Swagger UI and I have some problems with the header params for certain operations.
For example this is a curl that is working on my API:
curl -v -X GET -H 'Content-Type: application/json' -H 'Cookie: Y=COOKIE_CONTENT_Y;T=COOKIE_CONTENT_T' http://{remote.host}:4080/v1/myResource1
However, when I exercise the API with Swagger UI it fails. The Swagger API for the method is configured like this:
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get stuff", notes = "", response = MyResponse.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK"),
@ApiResponse(code = 500, message = "Internal Server Error."),
@ApiResponse(code = 400, message = "Bad Request"), @ApiResponse(code = 401, message = "Unauthorized") })
public Response getStuff(
@ApiParam(value = "It should contain the Y and T Cookies", required = true) @HeaderParam(HttpHeaders.COOKIE) String cookie,
@CookieParam("Y") String yCookie) throws BadRequestException, UnauthorizedException, InternalServerErrorException {
In the Swagger UI they appear tex-boxes to add the cookie params, however, when I execute the query, I can't see the Cookie sent on the request and it fails. This is the output I get from the Chrome dev tools:
Request URL:http://{remote.host}:4080/v1/myResource1
Request Method:GET
Status Code:401 Unauthorized
Request Headers
Accept:application/json
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,es;q=0.6
Connection:keep-alive
Host:{remote.host}:4080
Origin:null
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.152 Safari/537.36
Response Headers
Access-Control-Allow-Headers:Content-Type, Cookie
Access-Control-Allow-Methods:GET, POST, DELETE, PUT, OPTIONS
Access-Control-Allow-Origin:*
Content-Length:52
Content-Type:application/json
Server:Jetty(9.1.3.v20140225)
I've seen that adding "supportHeaderParams: true," to the dist/index.html in the Swagger UI could help, but it doesn't work for me. Can you help me with this?
Thanks in advance!
Francisco