We use Swashbuckle to document our web apis and use it to test our web avis. I want to know how you can pass multiple custom headers with different values ββfor each request using the Swagger user interface.
I saw an answer similar to the one below on the web to pass the header in the Swagger user interface, but couldn't tear it off. What is confusing about the SwaggerExtensions file. What is the purpose of this file and why is this file mentioned in the qualified js file name.
1. Add a new file called "SwaggerExtensions" and then add a new JS file called "onComplete.js", you need to change the build action for this file to "Embedded Resource".
2. Inside the "onComplete.js" file, paste the following code:
$('#input_apiKey').change(function () { var key = $('#input_apiKey')[0].value; if (key && key.trim() != "") { key = "Bearer " + key; window.authorizations.add("key", new ApiKeyAuthorization("Authorization", key, "header")); } });
3. Open the file "SwaggerConfig.cs" and inside the register method, paste the following code:
SwaggerUiConfig.Customize(c => { c.SupportHeaderParams = true; c.InjectJavaScript(typeof(SwaggerConfig).Assembly, "AngularJSAuthentication.API.SwaggerExtensions.onComplete.js"); });
asp.net-web-api swagger-ui
Kiran r
source share