1

I want to add a @ApiImplicitParam Springfox annotation to document on Swagger UI a cookie, required by the service

@GetMapping(value = "cookies")
public void methodA(
  @RequestHeader HttpHeaders headers) {
    service.checkCookie(headers);  
}

I'll try doing

@GetMapping(value = "cookies")
public void methodA(
  @ApiImplicitParam(name="cookie", paramType = "header", type = "string") @RequestHeader HttpHeaders headers) {
    service.checkCookie(headers);  
}

But in Swagger UI don't sent any cookie when I push on Execute button.

Developer tools

Cookie isn't sent, and return a Bad Request 400 code. But If I execute the curl printed, I obtain an OK status.

curl -k -i -X GET "https://localhost:8080/cookies" -H "cookie: KEY=VALUE"

HTTP/1.1 200

Also try with paramType annotation value cookie like this:

@GetMapping(value = "cookies")
public void methodA(
  @ApiImplicitParam(name="cookie", paramType = "cookie", type = "string") @RequestHeader HttpHeaders headers) {
    service.checkCookie(headers);  
}

With the same 400 error

albertoiNET
  • 1,280
  • 25
  • 34
  • 2
    Possible duplicate of [Sending cookie session ID with OpenAPI 3.0](https://stackoverflow.com/q/49272171/113116). Swagger UI cannot set the `Cookie` header because of browser security restrictions. More details here: https://github.com/swagger-api/swagger-js/issues/1163 – Helen Aug 19 '19 at 16:42

0 Answers0