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

[feat] Intercept the request for creating a dynamic scalarConfig. #165

Open
matvp91 opened this issue Oct 29, 2024 · 0 comments
Open

[feat] Intercept the request for creating a dynamic scalarConfig. #165

matvp91 opened this issue Oct 29, 2024 · 0 comments

Comments

@matvp91
Copy link

matvp91 commented Oct 29, 2024

The swagger plugin creates a new Elysia instance under the hood and threats the arguments as static.

const app = new Elysia()
    .use(swagger({
       documentation: { ... }
       scalarConfig: { ... }
    }))

Let's say I have a securitySchemes defined in the documentation. I'd like to change the scalarConfig to include a default bearer token when I pass it as a query param.

documentation: {
  ...
  components: {
    securitySchemes: {
      bearerAuth: {
        type: "http",
        scheme: "bearer",
        bearerFormat: "JWT",
      }
    }
  }
}
scalarConfig: {
  ...
  authentication: {
    preferredSecurityScheme: "bearerAuth",
    http: {
      basic: {},
      bearer: {
        token: query.token
      }
    }
  }
}

This way I could generate documentation with sane defaults for a specific user.

https://localhost:8080/swagger?token=...

I'm open to idea's and happy to provide a PR once we have a clearer path forward.

@matvp91 matvp91 changed the title [feat] Intercept the request for creating dynamic a scalarConfig. [feat] Intercept the request for creating a dynamic scalarConfig. Oct 29, 2024
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

1 participant