swagger-api / swagger-api/swagger-ui
Unable to get preauthorize to work
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Q&A (please complete the following information)
- OS: macOS
- Browser: chrome
- Version: latest
- Method of installation: downloaded from github release page
- Swagger-UI version: 4.15.5
- Swagger/OpenAPI version: Swagger 2.0
Content & configuration
I need to have all the APIs to include Authorization header as part of the call. Setting preauthorizeApiKey does not appears to be working in the v4.15.5. I tried to put this line inside the onComplete function, but still does not work. I am not using any npm package. This is directly using the dist/ standalone mentioned here.
Swagger/OpenAPI definition:
Unrelated
Swagger-UI configuration options:
window.ui = SwaggerUIBundle({
url: "./api.swagger.json",
dom_id: '#swagger-ui',
deepLinking: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout",
onComplete: () => {
ui.preauthorizeApiKey("key", "value");
}
});
Screenshots
How can we help?
I am not sure if this is a bug or not. I cannot get the Authorization header set.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report with the Swagger UI 4.15.5 dist/ standalone build and the shown onComplete call to preauthorizeApiKey. Inspect the preauthorization flow and verify whether the resulting API requests include the Authorization header. Done means the standalone configuration reliably applies the key to API calls, or the issue is documented as expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- authentication, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100