wordnik/swagger-ui — Issue #4: Parameters marked as type "header" are not place in the header.
Author: agileanimal
Created: 2011-10-10 06:15:47+00:00
State: open

I am trying to get a ruby project going with swagger - the API in question requires an API token be passed in the header.

In your examples you mark parameters as "header" but then it swagger-ui still places them in the query string - which only works for your API.

As a temps fix I am always making the token the first parameter and have make the following horrible, horrible hack to get things working; (in ```submitOperation``` of ```swagger-ui.js```)

```javascript

if (error_free) {
var params = form.serializeArray();
var token_name = params[0].name;
var token_value = params[0].value;
params.splice(0,1);
var invocationUrl = this.operation.invocationUrl(params);
$(".request_url", this.elementScope + "_content_sandbox_response").html(
"

" + invocationUrl + "

"
);
$.ajax(
{ url: invocationUrl, dataType: 'json', data: '{}', success: this.showResponse, beforeSend:
function (xhr) {
xhr.setRequestHeader(token_name, token_value);
}

}
).complete(this.showCompleteStatus).error(this.showErrorStatus);
}

```

Any thoughts on a permanent fix for this?