I want to send a request to my
ASP.NET WebApi2 application from Swagger UI. I need to add Authorization headers to the request. I have added my custom index.html file and modified the addApiKeyAuthorization() function to be able to send Authorization header with every request. The function looks like that:
function addApiKeyAuthorization() {
var key = encodeURIComponent($('#input_apiKey')[0].value);
if (key && key.trim() != "") {
var value = "auth-scheme customer_id=123456,order_id=56789,signature=hhhhjjjjkkkklllllll";
var authKeyHeader = new SwaggerClient.ApiKeyAuthorization("Authorization", value, "header");
window.swaggerUi.api.clientAuthorizations.add("Authorization", authKeyHeader);
}
}
At the moment the signature is hardcoded (I know exactly what parameter values to pass in in the request body for the signature to be valid).
In order to generate a signature dynamically for given parameters in the request body I need to use those parameters that are passed in in the request body. How can I access those parameters inside the addApiKeyAuthorization() function so that I could set the signature parameter in the Authorization header dynamically?