Skip to content

Bearer auth security type adds empty Authorization component #411

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

Closed
IanVS opened this issue Feb 8, 2023 · 5 comments
Closed

Bearer auth security type adds empty Authorization component #411

IanVS opened this issue Feb 8, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@IanVS
Copy link
Contributor

IanVS commented Feb 8, 2023

Describe the bug

When using bearer auth, there's an un-expandable Authorization box shown above the demo request box.

Expected behavior

Either it should show something useful, or just go away, I guess. Would be nice to show the description that I've added for the bearer auth, I suppose. Even better if I can customize this description per path+method, but I don't think that's part of the openapi spec.

Current behavior

An empty, unclickable box is shown.

Steps to reproduce

git clone https://github.com/IanVS/repro-docusaurus-openapi-issue.git
git checkout bearer-auth
npm i
npx docusaurus gen-api-docs all
npm start

Navigate to /docs/petstore/add-pet

Notice that there is an "Authorization" box, that looks clickable, but does not expand to show anything.

Honestly I'd love to be able to show the api token's "scopes" that are required (we use scoped keys), but I know that scopes are only supported by oidc and oauth. :(

Screenshots

image

Context

Not a huge deal, just strange to show a thing that does nothing.

Your Environment

@IanVS IanVS added the bug Something isn't working label Feb 8, 2023
@IanVS
Copy link
Contributor Author

IanVS commented Feb 8, 2023

My best bet might be to swizzle it, but I'm not sure how I'd be able to hack it to use some custom data per path+method. Nevermind, doesn't look like it's in the list of things that can be swizzled.

@sserrata
Copy link
Member

Hi @IanVS, thanks for reporting this issue. It's in our backlog to address with the goal to provide full coverage of all auth/security-scheme types.

@sserrata
Copy link
Member

Upon second inspection, it looks like the security scheme defined in your repro is missing a type. That said, I think may just return undefined if the selected auth/options doesn't have type defined.

Something like:

  if (options[selected]?.type === undefined) {
    return null;
  }

@IanVS
Copy link
Contributor Author

IanVS commented Feb 17, 2023

I followed the example from https://swagger.io/docs/specification/authentication/bearer-authentication/

  securitySchemes:
    BearerAuth:
      description: >
        An API key with permissions needed for the endpoint
      type: http
      scheme: bearer 

What is it that is missing? (I'm still learning the ins and outs of openapi).

@sserrata
Copy link
Member

You're correct, nothing is missing in your usage. I believe what is happening is that options is the union of security and securitySchemes which is resulting in type not being defined. Will need to debug a bit more to be sure.

@sserrata sserrata mentioned this issue Feb 17, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants