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

components.securitySchemes is missing from the generated openapi.json #160

Open
amritk opened this issue Oct 16, 2024 · 1 comment
Open

Comments

@amritk
Copy link

amritk commented Oct 16, 2024

As seen in this ticket, when you specify security on an endpoint, how can you get the securityScheme added to the components.securitySchemes in the openapi.json?

@periabyte
Copy link

periabyte commented Oct 22, 2024

@amritk I had the same problem, but based on this #8 component.securitySchemes should be placed inside the documentation property like

new Elysia().use(
  swagger({
    documentation: {
      components: {
        securitySchemes: {
          BearerAuth: {
            type: 'http',
            scheme: 'bearer',
            bearerFormat: 'JWT',
          },
        },
      },
    },
    scalarConfig: {
      authentication: {
        preferredSecurityScheme: 'BearerAuth',
      },
    },
  }),
).get(
  '/endpoint',
  () => 'endpoint',
  { detail: { security: [{ BearerAuth: [] }] }
);

this should be detailed in the documentation, took me a while to find out the proper configuration

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

2 participants