Support for changing api_key parameter name. Closes #36
This commit is contained in:
19
dist/lib/swagger.js
vendored
19
dist/lib/swagger.js
vendored
@@ -1,12 +1,10 @@
|
||||
// Generated by CoffeeScript 1.3.1
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
(function() {
|
||||
var SwaggerApi, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||
|
||||
SwaggerApi = (function() {
|
||||
|
||||
SwaggerApi.name = 'SwaggerApi';
|
||||
|
||||
SwaggerApi.prototype.discoveryUrl = "http://api.wordnik.com/v4/resources.json";
|
||||
|
||||
SwaggerApi.prototype.debug = false;
|
||||
@@ -25,6 +23,7 @@
|
||||
if (options.debug != null) {
|
||||
this.debug = options.debug;
|
||||
}
|
||||
this.apiKeyName = options.apiKeyName != null ? options.apiKeyName : 'api_key';
|
||||
if (options.apiKey != null) {
|
||||
this.api_key = options.apiKey;
|
||||
}
|
||||
@@ -124,7 +123,7 @@
|
||||
var sep;
|
||||
if ((this.api_key != null) && jQuery.trim(this.api_key).length > 0 && (url != null)) {
|
||||
sep = url.indexOf('?') > 0 ? '&' : '?';
|
||||
return url + sep + 'api_key=' + this.api_key;
|
||||
return url + sep + this.apiKeyName + '=' + this.api_key;
|
||||
} else {
|
||||
return url;
|
||||
}
|
||||
@@ -156,8 +155,6 @@
|
||||
|
||||
SwaggerResource = (function() {
|
||||
|
||||
SwaggerResource.name = 'SwaggerResource';
|
||||
|
||||
function SwaggerResource(resourceObj, api) {
|
||||
var parts,
|
||||
_this = this;
|
||||
@@ -236,8 +233,6 @@
|
||||
|
||||
SwaggerOperation = (function() {
|
||||
|
||||
SwaggerOperation.name = 'SwaggerOperation';
|
||||
|
||||
function SwaggerOperation(nickname, path, httpMethod, parameters, summary, resource) {
|
||||
var parameter, v, _i, _j, _len, _len1, _ref, _ref1,
|
||||
_this = this;
|
||||
@@ -355,7 +350,7 @@
|
||||
}
|
||||
}
|
||||
if (includeApiKey && (this.resource.api.api_key != null) && this.resource.api.api_key.length > 0) {
|
||||
args['api_key'] = this.resource.api.api_key;
|
||||
args[this.apiKeyName] = this.resource.api.api_key;
|
||||
}
|
||||
if (this.supportHeaderParams()) {
|
||||
queryParams = jQuery.param(this.getQueryParams(args));
|
||||
@@ -408,7 +403,7 @@
|
||||
}
|
||||
}
|
||||
if (includeApiKey && (this.resource.api.api_key != null) && this.resource.api.api_key.length > 0) {
|
||||
matchingParams['api_key'] = this.resource.api.api_key;
|
||||
matchingParams[this.resource.api.apiKeyName] = this.resource.api.api_key;
|
||||
}
|
||||
return matchingParams;
|
||||
};
|
||||
@@ -429,8 +424,6 @@
|
||||
|
||||
SwaggerRequest = (function() {
|
||||
|
||||
SwaggerRequest.name = 'SwaggerRequest';
|
||||
|
||||
function SwaggerRequest(type, url, headers, body, successCallback, errorCallback, operation) {
|
||||
var obj,
|
||||
_this = this;
|
||||
@@ -461,7 +454,7 @@
|
||||
}
|
||||
this.headers || (this.headers = {});
|
||||
if (this.operation.resource.api.api_key != null) {
|
||||
this.headers.api_key = this.operation.resource.api.api_key;
|
||||
this.headers[this.apiKeyName] = this.operation.resource.api.api_key;
|
||||
}
|
||||
if (this.headers.mock == null) {
|
||||
obj = {
|
||||
|
||||
Reference in New Issue
Block a user