{"action":"opened","issue":{"url":"https://api.github.com/repos/swagger-api/swagger-ui/issues/1984","repository_url":"https://api.github.com/repos/swagger-api/swagger-ui","labels_url":"https://api.github.com/repos/swagger-api/swagger-ui/issues/1984/labels{/name}","comments_url":"https://api.github.com/repos/swagger-api/swagger-ui/issues/1984/comments","events_url":"https://api.github.com/repos/swagger-api/swagger-ui/issues/1984/events","html_url":"https://github.com/swagger-api/swagger-ui/issues/1984","id":135685408,"number":1984,"title":"could not add both custom sign header and Authorization at the same time","user":{"login":"ole3021","id":2676686,"avatar_url":"https://avatars.githubusercontent.com/u/2676686?v=3","gravatar_id":"","url":"https://api.github.com/users/ole3021","html_url":"https://github.com/ole3021","followers_url":"https://api.github.com/users/ole3021/followers","following_url":"https://api.github.com/users/ole3021/following{/other_user}","gists_url":"https://api.github.com/users/ole3021/gists{/gist_id}","starred_url":"https://api.github.com/users/ole3021/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ole3021/subscriptions","organizations_url":"https://api.github.com/users/ole3021/orgs","repos_url":"https://api.github.com/users/ole3021/repos","events_url":"https://api.github.com/users/ole3021/events{/privacy}","received_events_url":"https://api.github.com/users/ole3021/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-02-23T09:38:39Z","updated_at":"2016-02-23T09:38:39Z","closed_at":null,"body":"hi \r\n\r\nim use the `swagger-ui 2.1.4` 's dist pages in my project\r\nand i have the follow problem \r\ni can init `authorization` or  customised `sign` separately, but i cant do both at the same time. \r\n\r\n```javascript\r\n$(function () {\r\n  var url = window.location.search.match(/url=([^&]+)/);\r\n  if (url && url.length > 1) {\r\n    url = decodeURIComponent(url[1]);\r\n  } else {\r\n    url = \"http://localhost:3000/swagger.json\";\r\n  }\r\n\r\n  // Pre load translate...\r\n  if(window.SwaggerTranslator) {\r\n    window.SwaggerTranslator.translate();\r\n  }\r\n  addBasicAuth();\r\n\r\n  window.swaggerUi = new SwaggerUi({\r\n    url: url,\r\n    dom_id: \"swagger-ui-container\",\r\n    supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],\r\n    onComplete: function(swaggerApi, swaggerUi){\r\n      if(typeof initOAuth == \"function\") {\r\n        initOAuth({\r\n          clientId: \"your-client-id\",\r\n          clientSecret: \"your-client-secret-if-required\",\r\n          realm: \"your-realms\",\r\n          appName: \"your-app-name\",\r\n          scopeSeparator: \",\",\r\n          additionalQueryStringParams: {}\r\n        });\r\n      }\r\n\r\n      if(window.SwaggerTranslator) {\r\n        window.SwaggerTranslator.translate();\r\n      }\r\n      console.log(\"swagger inited\");\r\n      addApiKeyAuthorization();\r\n      basicAuth();\r\n      addSignAuth();\r\n    },\r\n    onFailure: function(data) {\r\n      log(\"Unable to Load SwaggerUI\");\r\n    },\r\n    docExpansion: \"none\",\r\n    jsonEditor: false,\r\n    apisSorter: \"alpha\",\r\n    defaultModelRendering: 'schema',\r\n    showRequestHeaders: false\r\n  });\r\n\r\n  function addApiKeyAuthorization(){\r\n    var key = encodeURIComponent($('#input_apiKey')[0].value);\r\n    if(key && key.trim() != \"\") {\r\n        var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization(\"api_key\", key, \"query\");\r\n        window.swaggerUi.api.clientAuthorizations.add(\"api_key\", apiKeyAuth);\r\n        log(\"added key \" + key);\r\n    }\r\n  }\r\n\r\n  // basic Auth\r\n  function addBasicAuth() {\r\n    var basicAuthUI =\r\n        '<div class=\"input\"><input placeholder=\"username\" id=\"input_username\" name=\"username\" type=\"text\" size=\"10\"></div>' +\r\n        '<div class=\"input\"><input placeholder=\"password\" id=\"input_password\" name=\"password\" type=\"password\" size=\"10\"></div>';\r\n    $(basicAuthUI).insertBefore('#api_selector div.input:last-child');\r\n    $(\"#input_apiKey\").hide();\r\n\r\n    // init user name adn passworkd\r\n    var apiUser = \"user\";\r\n    var apiPass = \"blabla\";\r\n    $('#input_username').val(apiUser);\r\n    $('#input_password').val(apiPass);\r\n    console.log(\"UI completed\");\r\n  }\r\n\r\n  function basicAuth() {\r\n      var username = $('#input_username').val();\r\n      var password = $('#input_password').val();\r\n      console.log(\"adding authorization\"+ username);\r\n      if (username && username.trim() != \"\" && password && password.trim() != \"\") {\r\n          var basicAuth = new SwaggerClient.PasswordAuthorization(\"basicAuth\", username, password);\r\n          window.swaggerUi.api.clientAuthorizations.add(\"basicAuth\", basicAuth);\r\n          console.log(\"authorization added: username = \" + username + \", password = \" + password);\r\n      }\r\n  }\r\n\r\n  // sign authentication\r\n  function addSignAuth() {\r\n    var CustomRequestSigner = function(name) {\r\n      console.log(\"signing\");\r\n      this.name = name;\r\n    };\r\n\r\n    CustomRequestSigner.prototype.apply = function(obj, authorizations) {\r\n      var hashFunction = this._btoa;\r\n      var hash = obj.url;\r\n      console.log(\"sign: >>>\" + hash);\r\n      obj.headers[\"sign\"] = hash;\r\n      return true;\r\n    };\r\n\r\n\r\n    window.swaggerUi.api.clientAuthorizations.add('basicAuth', new CustomRequestSigner());\r\n  }\r\n\r\n  window.swaggerUi.load();\r\n\r\n  $('#input_apiKey').change(addApiKeyAuthorization);\r\n  $('#input_username').change(basicAuth);\r\n  $('#input_password').change(basicAuth);\r\n\r\n});\r\n\r\n```\r\nwhen i execute the code i found the obj `window.swaggerUi.api.clientAuthorizations.authz` 's basicAuth is overwriten by the sign method `CustomRequestSigner`, and i can only see the `sing` header in the request beside if i change \r\n`    window.swaggerUi.api.clientAuthorizations.add('basicAuth', new CustomRequestSigner());`\r\n to \r\n`    window.swaggerUi.api.clientAuthorizations.add('sign', new CustomRequestSigner());`\r\ni can get bot `basicAuth` and `sing` property in `window.swaggerUi.api.clientAuthorizations.authz`, \r\nbut no `sign` header in the request header....\r\n\r\nim really confusing now , could anyone explain how to use these method to add both `authorization` and `sign` header plz.. \r\n\r\nby the way here is my yaml file \r\n\r\n```yaml\r\n# this is an example of the Uber API\r\n# as a demonstration of an API spec in YAML\r\nswagger: '2.0'\r\ninfo:\r\n  title: test\r\n  description: test\r\n  version: \"1.1.0\"\r\n# the domain of the service\r\nhost: localhost:3000\r\n# array of all schemes that your API supports\r\nschemes:\r\n  - http\r\nsecurityDefinitions:\r\n  basicAuth:\r\n    type: basic\r\n# will be prefixed to all paths\r\nbasePath: /api/v1.1\r\nproduces:\r\n  - application/json\r\npaths:\r\n  /actions:\r\n    get:\r\n      security:\r\n      - basicAuth: []\r\n      summary: an example action\r\n      description: |\r\n```"}}