Support for changing api_key parameter name. Closes #36
This commit is contained in:
@@ -44,7 +44,10 @@ _Note that for POST/PUT body, you'd need to paste in the request data in an appr
|
|||||||
### Header Parameters
|
### Header Parameters
|
||||||
header parameters aere supported. However because of [Cross-Origin Resource Sharing](http://www.w3.org/TR/cors/) restrictions, swagger-ui, by default, does not send header parameters. This can be enabled by [setting the supportHeaderParams to false when creating SwaggerUI instance](https://github.com/wordnik/swagger-ui/blob/f2e63c65a759421aad590b7275371cd0c06c74ea/src/main/html/index.html#L48).
|
header parameters aere supported. However because of [Cross-Origin Resource Sharing](http://www.w3.org/TR/cors/) restrictions, swagger-ui, by default, does not send header parameters. This can be enabled by [setting the supportHeaderParams to false when creating SwaggerUI instance](https://github.com/wordnik/swagger-ui/blob/f2e63c65a759421aad590b7275371cd0c06c74ea/src/main/html/index.html#L48).
|
||||||
|
|
||||||
|
### Api Key Parameter
|
||||||
|
If you enter an api key in swagger-ui, it sends a parameter named 'api_key' as a query (or as a header param if you've enabled it as described above). You may not want to use the name 'api_key' as the name of this parameter. You can change its name by setting the _apiKeyName_ parameter when you instantiate a SwaggerUI instance. For example to call it 'sessionId'
|
||||||
|
|
||||||
|
apiKeyName: "sessionId"
|
||||||
|
|
||||||
How to Improve It
|
How to Improve It
|
||||||
-----------------
|
-----------------
|
||||||
|
|||||||
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() {
|
(function() {
|
||||||
var SwaggerApi, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
var SwaggerApi, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
||||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||||
|
|
||||||
SwaggerApi = (function() {
|
SwaggerApi = (function() {
|
||||||
|
|
||||||
SwaggerApi.name = 'SwaggerApi';
|
|
||||||
|
|
||||||
SwaggerApi.prototype.discoveryUrl = "http://api.wordnik.com/v4/resources.json";
|
SwaggerApi.prototype.discoveryUrl = "http://api.wordnik.com/v4/resources.json";
|
||||||
|
|
||||||
SwaggerApi.prototype.debug = false;
|
SwaggerApi.prototype.debug = false;
|
||||||
@@ -25,6 +23,7 @@
|
|||||||
if (options.debug != null) {
|
if (options.debug != null) {
|
||||||
this.debug = options.debug;
|
this.debug = options.debug;
|
||||||
}
|
}
|
||||||
|
this.apiKeyName = options.apiKeyName != null ? options.apiKeyName : 'api_key';
|
||||||
if (options.apiKey != null) {
|
if (options.apiKey != null) {
|
||||||
this.api_key = options.apiKey;
|
this.api_key = options.apiKey;
|
||||||
}
|
}
|
||||||
@@ -124,7 +123,7 @@
|
|||||||
var sep;
|
var sep;
|
||||||
if ((this.api_key != null) && jQuery.trim(this.api_key).length > 0 && (url != null)) {
|
if ((this.api_key != null) && jQuery.trim(this.api_key).length > 0 && (url != null)) {
|
||||||
sep = url.indexOf('?') > 0 ? '&' : '?';
|
sep = url.indexOf('?') > 0 ? '&' : '?';
|
||||||
return url + sep + 'api_key=' + this.api_key;
|
return url + sep + this.apiKeyName + '=' + this.api_key;
|
||||||
} else {
|
} else {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
@@ -156,8 +155,6 @@
|
|||||||
|
|
||||||
SwaggerResource = (function() {
|
SwaggerResource = (function() {
|
||||||
|
|
||||||
SwaggerResource.name = 'SwaggerResource';
|
|
||||||
|
|
||||||
function SwaggerResource(resourceObj, api) {
|
function SwaggerResource(resourceObj, api) {
|
||||||
var parts,
|
var parts,
|
||||||
_this = this;
|
_this = this;
|
||||||
@@ -236,8 +233,6 @@
|
|||||||
|
|
||||||
SwaggerOperation = (function() {
|
SwaggerOperation = (function() {
|
||||||
|
|
||||||
SwaggerOperation.name = 'SwaggerOperation';
|
|
||||||
|
|
||||||
function SwaggerOperation(nickname, path, httpMethod, parameters, summary, resource) {
|
function SwaggerOperation(nickname, path, httpMethod, parameters, summary, resource) {
|
||||||
var parameter, v, _i, _j, _len, _len1, _ref, _ref1,
|
var parameter, v, _i, _j, _len, _len1, _ref, _ref1,
|
||||||
_this = this;
|
_this = this;
|
||||||
@@ -355,7 +350,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (includeApiKey && (this.resource.api.api_key != null) && this.resource.api.api_key.length > 0) {
|
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()) {
|
if (this.supportHeaderParams()) {
|
||||||
queryParams = jQuery.param(this.getQueryParams(args));
|
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) {
|
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;
|
return matchingParams;
|
||||||
};
|
};
|
||||||
@@ -429,8 +424,6 @@
|
|||||||
|
|
||||||
SwaggerRequest = (function() {
|
SwaggerRequest = (function() {
|
||||||
|
|
||||||
SwaggerRequest.name = 'SwaggerRequest';
|
|
||||||
|
|
||||||
function SwaggerRequest(type, url, headers, body, successCallback, errorCallback, operation) {
|
function SwaggerRequest(type, url, headers, body, successCallback, errorCallback, operation) {
|
||||||
var obj,
|
var obj,
|
||||||
_this = this;
|
_this = this;
|
||||||
@@ -461,7 +454,7 @@
|
|||||||
}
|
}
|
||||||
this.headers || (this.headers = {});
|
this.headers || (this.headers = {});
|
||||||
if (this.operation.resource.api.api_key != null) {
|
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) {
|
if (this.headers.mock == null) {
|
||||||
obj = {
|
obj = {
|
||||||
|
|||||||
16
dist/swagger-ui.js
vendored
16
dist/swagger-ui.js
vendored
@@ -773,18 +773,16 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Generated by CoffeeScript 1.3.1
|
// Generated by CoffeeScript 1.3.3
|
||||||
(function() {
|
(function() {
|
||||||
var HeaderView, MainView, OperationView, ParameterView, ResourceView, SwaggerUi,
|
var HeaderView, MainView, OperationView, ParameterView, ResourceView, SwaggerUi,
|
||||||
__hasProp = {}.hasOwnProperty,
|
__hasProp = {}.hasOwnProperty,
|
||||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
|
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||||
|
|
||||||
SwaggerUi = (function(_super) {
|
SwaggerUi = (function(_super) {
|
||||||
|
|
||||||
__extends(SwaggerUi, _super);
|
__extends(SwaggerUi, _super);
|
||||||
|
|
||||||
SwaggerUi.name = 'SwaggerUi';
|
|
||||||
|
|
||||||
function SwaggerUi() {
|
function SwaggerUi() {
|
||||||
return SwaggerUi.__super__.constructor.apply(this, arguments);
|
return SwaggerUi.__super__.constructor.apply(this, arguments);
|
||||||
}
|
}
|
||||||
@@ -892,8 +890,6 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
|
|||||||
|
|
||||||
__extends(HeaderView, _super);
|
__extends(HeaderView, _super);
|
||||||
|
|
||||||
HeaderView.name = 'HeaderView';
|
|
||||||
|
|
||||||
function HeaderView() {
|
function HeaderView() {
|
||||||
return HeaderView.__super__.constructor.apply(this, arguments);
|
return HeaderView.__super__.constructor.apply(this, arguments);
|
||||||
}
|
}
|
||||||
@@ -960,8 +956,6 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
|
|||||||
|
|
||||||
__extends(MainView, _super);
|
__extends(MainView, _super);
|
||||||
|
|
||||||
MainView.name = 'MainView';
|
|
||||||
|
|
||||||
function MainView() {
|
function MainView() {
|
||||||
return MainView.__super__.constructor.apply(this, arguments);
|
return MainView.__super__.constructor.apply(this, arguments);
|
||||||
}
|
}
|
||||||
@@ -1002,8 +996,6 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
|
|||||||
|
|
||||||
__extends(ResourceView, _super);
|
__extends(ResourceView, _super);
|
||||||
|
|
||||||
ResourceView.name = 'ResourceView';
|
|
||||||
|
|
||||||
function ResourceView() {
|
function ResourceView() {
|
||||||
return ResourceView.__super__.constructor.apply(this, arguments);
|
return ResourceView.__super__.constructor.apply(this, arguments);
|
||||||
}
|
}
|
||||||
@@ -1039,8 +1031,6 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
|
|||||||
|
|
||||||
__extends(OperationView, _super);
|
__extends(OperationView, _super);
|
||||||
|
|
||||||
OperationView.name = 'OperationView';
|
|
||||||
|
|
||||||
function OperationView() {
|
function OperationView() {
|
||||||
return OperationView.__super__.constructor.apply(this, arguments);
|
return OperationView.__super__.constructor.apply(this, arguments);
|
||||||
}
|
}
|
||||||
@@ -1197,8 +1187,6 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
|
|||||||
|
|
||||||
__extends(ParameterView, _super);
|
__extends(ParameterView, _super);
|
||||||
|
|
||||||
ParameterView.name = 'ParameterView';
|
|
||||||
|
|
||||||
function ParameterView() {
|
function ParameterView() {
|
||||||
return ParameterView.__super__.constructor.apply(this, arguments);
|
return ParameterView.__super__.constructor.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
|||||||
2
dist/swagger-ui.min.js
vendored
2
dist/swagger-ui.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,12 +1,10 @@
|
|||||||
// Generated by CoffeeScript 1.3.1
|
// Generated by CoffeeScript 1.3.3
|
||||||
(function() {
|
(function() {
|
||||||
var SwaggerApi, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
var SwaggerApi, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
||||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||||
|
|
||||||
SwaggerApi = (function() {
|
SwaggerApi = (function() {
|
||||||
|
|
||||||
SwaggerApi.name = 'SwaggerApi';
|
|
||||||
|
|
||||||
SwaggerApi.prototype.discoveryUrl = "http://api.wordnik.com/v4/resources.json";
|
SwaggerApi.prototype.discoveryUrl = "http://api.wordnik.com/v4/resources.json";
|
||||||
|
|
||||||
SwaggerApi.prototype.debug = false;
|
SwaggerApi.prototype.debug = false;
|
||||||
@@ -25,6 +23,7 @@
|
|||||||
if (options.debug != null) {
|
if (options.debug != null) {
|
||||||
this.debug = options.debug;
|
this.debug = options.debug;
|
||||||
}
|
}
|
||||||
|
this.apiKeyName = options.apiKeyName != null ? options.apiKeyName : 'api_key';
|
||||||
if (options.apiKey != null) {
|
if (options.apiKey != null) {
|
||||||
this.api_key = options.apiKey;
|
this.api_key = options.apiKey;
|
||||||
}
|
}
|
||||||
@@ -124,7 +123,7 @@
|
|||||||
var sep;
|
var sep;
|
||||||
if ((this.api_key != null) && jQuery.trim(this.api_key).length > 0 && (url != null)) {
|
if ((this.api_key != null) && jQuery.trim(this.api_key).length > 0 && (url != null)) {
|
||||||
sep = url.indexOf('?') > 0 ? '&' : '?';
|
sep = url.indexOf('?') > 0 ? '&' : '?';
|
||||||
return url + sep + 'api_key=' + this.api_key;
|
return url + sep + this.apiKeyName + '=' + this.api_key;
|
||||||
} else {
|
} else {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
@@ -156,8 +155,6 @@
|
|||||||
|
|
||||||
SwaggerResource = (function() {
|
SwaggerResource = (function() {
|
||||||
|
|
||||||
SwaggerResource.name = 'SwaggerResource';
|
|
||||||
|
|
||||||
function SwaggerResource(resourceObj, api) {
|
function SwaggerResource(resourceObj, api) {
|
||||||
var parts,
|
var parts,
|
||||||
_this = this;
|
_this = this;
|
||||||
@@ -236,8 +233,6 @@
|
|||||||
|
|
||||||
SwaggerOperation = (function() {
|
SwaggerOperation = (function() {
|
||||||
|
|
||||||
SwaggerOperation.name = 'SwaggerOperation';
|
|
||||||
|
|
||||||
function SwaggerOperation(nickname, path, httpMethod, parameters, summary, resource) {
|
function SwaggerOperation(nickname, path, httpMethod, parameters, summary, resource) {
|
||||||
var parameter, v, _i, _j, _len, _len1, _ref, _ref1,
|
var parameter, v, _i, _j, _len, _len1, _ref, _ref1,
|
||||||
_this = this;
|
_this = this;
|
||||||
@@ -355,7 +350,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (includeApiKey && (this.resource.api.api_key != null) && this.resource.api.api_key.length > 0) {
|
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()) {
|
if (this.supportHeaderParams()) {
|
||||||
queryParams = jQuery.param(this.getQueryParams(args));
|
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) {
|
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;
|
return matchingParams;
|
||||||
};
|
};
|
||||||
@@ -429,8 +424,6 @@
|
|||||||
|
|
||||||
SwaggerRequest = (function() {
|
SwaggerRequest = (function() {
|
||||||
|
|
||||||
SwaggerRequest.name = 'SwaggerRequest';
|
|
||||||
|
|
||||||
function SwaggerRequest(type, url, headers, body, successCallback, errorCallback, operation) {
|
function SwaggerRequest(type, url, headers, body, successCallback, errorCallback, operation) {
|
||||||
var obj,
|
var obj,
|
||||||
_this = this;
|
_this = this;
|
||||||
@@ -461,7 +454,7 @@
|
|||||||
}
|
}
|
||||||
this.headers || (this.headers = {});
|
this.headers || (this.headers = {});
|
||||||
if (this.operation.resource.api.api_key != null) {
|
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) {
|
if (this.headers.mock == null) {
|
||||||
obj = {
|
obj = {
|
||||||
|
|||||||
Reference in New Issue
Block a user