Skip to content

Instantly share code, notes, and snippets.

@ponelat
Last active February 25, 2017 15:21
Show Gist options
  • Save ponelat/b5ff602aa56d80f7b614 to your computer and use it in GitHub Desktop.
Save ponelat/b5ff602aa56d80f7b614 to your computer and use it in GitHub Desktop.
//...
window.swaggerUi = new SwaggerUi({
url: url,
dom_id: "swagger-ui-container",
authorizations: {
someName: function() {
// This function will get called /before/ each request
// ... UNLESS you have a 'security' tag in the swagger.json file, in which case you must add 'someName' to the list of auths.
console.log('explore the request object...',this) // Take a look in the console tab to see what's available.
this.headers['x-swagger'] = 'value'; // Example header
return true; // there is a bug, fixed but not in develop_2.0 where returning true will only process _one_ interceptor, you can leave this if it's your only interceptor and when the fix is in, it'll work as expected
}
}
// ...........
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment