javacookiesswaggerparam

Swagger - Issue using @ApiParam with @CookieParam


I'm using Swagger 1.3.10 and am trying to get the Swagger UI to functionally accept a cookie parameter for a REST service. Here's an example of my Java code:

    public Response getUserInfo(
    @Context HttpHeaders headers, 
    @ApiParam(value="Enter brand code as an Integer", defaultValue="101", required=true) @CookieParam(value = "userBrand") String brand)

Now the actual Swagger UI renders just fine actually...it even populates the default value with "101" in this case. The problem is when I click "Try it Out" the brand parameter is always coming through as null.

Seems like I'm missing something simple here...any thoughts?

Thanks a lot!


Solution

  • Cookie parameters are not really supported by Swagger. Swagger-core generates them as cookie parameters, but they are not supported by the other tools as that's not an official part of the spec.