Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to enable withCredentials #299

Open
JonMoore46 opened this issue Jun 16, 2022 · 4 comments
Open

Is it possible to enable withCredentials #299

JonMoore46 opened this issue Jun 16, 2022 · 4 comments

Comments

@JonMoore46
Copy link

JonMoore46 commented Jun 16, 2022

As far as I can tell it should be possible to now enable auth cookies to be sent with requests via swagger-ui - swagger-api/swagger-js#1163.

However I can't seem to work out how to enable this.

I have tried

const swaggerOptions: swaggerJSDoc.OAS3Options = {
  definition: {
    openapi: "3.0.0",
    info: {
      title: "Service",
      version: "0.0.0",
    },
    components: {
      securitySchemes: {
        exampleCookie: {
          name: "example",
          type: "apiKey",
          in: "cookie",
        },
      },
    },
  },
  apis: [path.join(__dirname, "../routes/*.js")],
};

export const openApiSpecification = swaggerJsdoc(swaggerOptions);

Then in my main app.js file

app.use(
    "/api/api-docs",
    swaggerUi.serve,
    swaggerUi.setup(openApiSpecification, { swaggerOptions: { withCredentials: true } })
  );

But with no luck and can't seem to figure it out.

Any help appreciated.

@scottie1984
Copy link
Owner

Not familiar with this setting however setting it through to swaggerOptions should work

@airedwin
Copy link

I think I have the same question, I want to enable authenticated requests in the "Try it out". Right now it's not sending my bearer auth info when I "Execute". I tried the withCredentials: true as well.

@sophie-pan
Copy link

any update ?

@Rikhart
Copy link

Rikhart commented Nov 9, 2024

any update about this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants