Swagger-ui: How to send cookies in request (swagger-ui 3.x)

Created on 11 Apr 2017  路  7Comments  路  Source: swagger-api/swagger-ui

if set "enableCookies: true" in swagger-ui 2.x, it will send cookies in request.
But it don't work in 3.x.
What should I do?

P2 try-it-out lock-bot feature 3.x

Most helpful comment

__Not a robust solution__
currently the latest version(3.9.3)
edit dist/index.html

     layout: "StandaloneLayout"
   })

+  ui.fn.fetch.withCredentials = true
   window.ui = ui

then work fine.

All 7 comments

At the moment, that configuration is not yet available in 3.x. If you require it, either use 2.x or consider submitting a PR to 3.x to add support for it.

Just fired it up and having the same problem. But there is an option in the authorize modal to put in a cookie. Am I correct in assuming @HunDunDM had that option too, and it did not work?

Or was that input field in the modal added since then, and it's supposed to work now? Confused.

still not work now. I am waiting for this PR

__Not a robust solution__
currently the latest version(3.9.3)
edit dist/index.html

     layout: "StandaloneLayout"
   })

+  ui.fn.fetch.withCredentials = true
   window.ui = ui

then work fine.

  • ui.fn.fetch.withCredentials = true
    --> did not work for me

+1 to add cookie management in Swagger 3... natively

Crazy to have a spec, without proper implementation of it. Without any warning
We choose Swagger to this spec, so maybe it may be useful to change of tool

ui.fn.fetch.withCredentials = true

This worked for me. Using Firefox 59.0.2 the CORS Everywhere extension

I am slightly confused regarding what this is supposed to do?

I am looking for a way for Swagger UI to load the Swagger JSON from a CORS location (the thing which is specified via ?url=...), passing the Cookie information when doing that. Is this what it's supposed to do?

If so, it doesn't work in neither Safari nor Chrome (on macOS).

Was this page helpful?
0 / 5 - 0 ratings