Last active
July 19, 2017 20:28
-
-
Save ponelat/05c775d06397b24811a4 to your computer and use it in GitHub Desktop.
Swagger-UI: Custom auth function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This can only get called from within the success handler, as we need swagger-client to be instantiated. | |
function addApiKeyAuthorization(){ | |
var key = encodeURIComponent($('#input_apiKey')[0].value); | |
if(key && key.trim() != "") { | |
var someAweseomAuth = new SwaggerClient.PasswordAuthorization("yourAuthName", "some user", "some password"); | |
window.swaggerUi.api.clientAuthorizations.add("yourAuthName", someAweseomAuth); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice.