stoplightio / elements

Build beautiful, interactive API Docs with embeddable React or Web Components, powered by OpenAPI and Markdown.
https://stoplight.io/open-source/elements/
Apache License 2.0
1.6k stars 189 forks source link

API with Set-Cookie not working #2596

Open TheZwieback opened 2 weeks ago

TheZwieback commented 2 weeks ago

I have an API that returns an Set-Cookie header but the browser does not set the cookie properly using the elements openapi renderer for this endpoint. Other OpenAPI renderer work in this case. My guess is that the reason are omitted credentials see here: https://github.com/stoplightio/elements/blob/e0b10da220e9e9b49b2ec94fb1fa94d534a6a44f/packages/elements-core/src/components/TryIt/build-request.ts#L133

Context

Can't do basic testing via the UI as cookies are used in other API endpoints.

Current Behavior

Cookies not set in chrome or other browsers.

Expected Behavior

Cookie should be set.

Possible Workaround/Solution

None.

Steps to Reproduce

Don't have a live server sorry. Any API framework should be possible to write an endpoint in few lines. I have a Python litestar example if that helps, let me know.

Environment

saper commented 1 week ago

Does it work if you set Cookie as a header parameter and enter the value?

brendarearden commented 4 days ago

https://docs.stoplight.io/docs/elements/b074dc47b2826-elements-configuration-options Could you try using the tryItCredentialsPolicy and set it to include or same-origin (depending on your use case) and see if that resolves your issue?