swagger-api / swagger-api/swagger-ui
SwaggerUI bundle - Cancel request for Spec on page load
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Hi, I need to cancel the initial request for the swaggerspec in SwaggerUI Bundle. I need the user to enter their credentials first and then hit the Explore button.
I have tried assigning a requestInterceptor. In here I am able to do things like Adding headers etc, but am not able to cancel the request
e.g
requestInterceptor: function (req) {
if (req.loadSpec && req.method != "OPTIONS") {
if (!($('#input_username').val() === undefined)) {
var hash = btoa($('#input_username').val() + ":" + $('#input_password').val());
headers['Authorization'] = "Basic " + hash;
req.loadSpec = true;
}
else {
alert('Setting loadspec to false');
req.loadSpec = false;
//Cancel the request here!!!???
}
}
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
Start by tracing SwaggerUI Bundle's initial spec-loading request and how requestInterceptor handles requests, using the behavior described in the issue as the entry point. Done means the initial spec request waits until the user enters credentials and selects Explore, while subsequent requests continue to work normally.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100