cookies - How to maintain session in swagger editor -


i using swagger building api documentation. new it. doing logging in first , giving call list api. session, cookies not maintained, list call not getting executed. need first login application , give call list. how can in swagger editor http://editor.swagger.io/#/

thankyou

i spent time struggling same question , far can tell swagger editor not make api calls xhr.withcredentials = true, means browser not send cookies if server's cors policy allows it. there's been discussion of updating swagger editor allow option (e.g., https://github.com/swagger-api/swagger-js/issues/251), doesn't appear has been done quite yet.

your best option avoid entire cross-origin security issue hosting swagger editor on own domain. 1 of suggestions: https://github.com/swagger-api/swagger-editor/blob/master/docs/cors.md#host-swagger-editor-in-your-own-domain. run if 1 of own apps on dev site.

another suggestion disable chrome web security: https://github.com/swagger-api/swagger-editor/blob/master/docs/cors.md#run-swagger-editor-in-a-browser-that-ignores-http-access-control. haven't tried may not work because swagger editor still not setting xhr request appropriately.

finally, if you're familiar docker, can run swagger editor docker instance , link up. complicated accomplished by:

  • running our backend inside docker container
  • running swagger editor instance inside docker container on same network (https://hub.docker.com/r/swaggerapi/swagger-editor/)
  • running nginx reverse proxy server inside third docker container such requests to, e.g., http://localhost/dev/swagger-editor/ proxy-forwarded swagger docker container , requests http://localhost/api/ proxy-forwarded backend. way browser sees requests localhost , works fine.

but need willing docker , nginx reverse proxy configs before having reasonable expectation you'll successful this. otherwise rabbit hole. luck!


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -