fixed #340 with empty body, updated swagger-js
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// swagger.js
|
||||
// version 2.0.30
|
||||
// version 2.0.31
|
||||
|
||||
var __bind = function(fn, me){
|
||||
return function(){
|
||||
@@ -57,24 +57,24 @@ Object.keys = Object.keys || (function () {
|
||||
'constructor'
|
||||
],
|
||||
DontEnumsLength = DontEnums.length;
|
||||
|
||||
|
||||
return function (o) {
|
||||
if (typeof o != "object" && typeof o != "function" || o === null)
|
||||
throw new TypeError("Object.keys called on a non-object");
|
||||
|
||||
|
||||
var result = [];
|
||||
for (var name in o) {
|
||||
if (hasOwnProperty.call(o, name))
|
||||
result.push(name);
|
||||
}
|
||||
|
||||
|
||||
if (hasDontEnumBug) {
|
||||
for (var i = 0; i < DontEnumsLength; i++) {
|
||||
if (hasOwnProperty.call(o, DontEnums[i]))
|
||||
result.push(DontEnums[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
@@ -87,6 +87,7 @@ var SwaggerApi = function(url, options) {
|
||||
this.authorizations = null;
|
||||
this.authorizationScheme = null;
|
||||
this.info = null;
|
||||
this.useJQuery = false;
|
||||
|
||||
options = (options||{});
|
||||
if (url)
|
||||
@@ -103,6 +104,9 @@ var SwaggerApi = function(url, options) {
|
||||
if (options.success != null)
|
||||
this.success = options.success;
|
||||
|
||||
if (typeof options.useJQuery === 'boolean')
|
||||
this.useJQuery = options.useJQuery;
|
||||
|
||||
this.failure = options.failure != null ? options.failure : function() {};
|
||||
this.progress = options.progress != null ? options.progress : function() {};
|
||||
if (options.success != null)
|
||||
@@ -478,8 +482,7 @@ SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes,
|
||||
|
||||
SwaggerResource.prototype.sanitize = function(nickname) {
|
||||
var op;
|
||||
op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|./?,\\'""-]/g, '_');
|
||||
//'
|
||||
op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|.\/?,\\'""-]/g, '_');
|
||||
op = op.replace(/((_){2,})/g, '_');
|
||||
op = op.replace(/^(_)*/g, '');
|
||||
op = op.replace(/([_])*$/g, '');
|
||||
@@ -812,7 +815,7 @@ SwaggerOperation.prototype.getSampleJSON = function(type, models) {
|
||||
else
|
||||
return JSON.stringify(val, null, 2);
|
||||
}
|
||||
else
|
||||
else
|
||||
return val;
|
||||
}
|
||||
};
|
||||
@@ -1073,7 +1076,7 @@ SwaggerOperation.prototype.formatXml = function(xml) {
|
||||
var SwaggerRequest = function(type, url, params, opts, successCallback, errorCallback, operation, execution) {
|
||||
var _this = this;
|
||||
var errors = [];
|
||||
this.useJQuery = (typeof operation.useJQuery !== 'undefined' ? operation.useJQuery : null);
|
||||
this.useJQuery = (typeof operation.resource.useJQuery !== 'undefined' ? operation.resource.useJQuery : null);
|
||||
this.type = (type||errors.push("SwaggerRequest type is required (get/post/put/delete/patch/options)."));
|
||||
this.url = (url||errors.push("SwaggerRequest url is required."));
|
||||
this.params = params;
|
||||
@@ -1121,6 +1124,8 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
|
||||
else
|
||||
requestContentType = "application/x-www-form-urlencoded";
|
||||
}
|
||||
else if (this.type == "DELETE")
|
||||
body = "{}";
|
||||
else if (this.type != "DELETE")
|
||||
requestContentType = null;
|
||||
}
|
||||
@@ -1259,9 +1264,16 @@ SwaggerHttp.prototype.isIE8 = function() {
|
||||
};
|
||||
|
||||
/*
|
||||
* JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic
|
||||
* JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic.
|
||||
* NOTE: when jQuery is available it will export both '$' and 'jQuery' to the global space.
|
||||
* Since we are using closures here we need to alias it for internal use.
|
||||
*/
|
||||
var JQueryHttpClient = function(options) {}
|
||||
var JQueryHttpClient = function(options) {
|
||||
"use strict";
|
||||
if(!jQuery){
|
||||
var jQuery = window.jQuery;
|
||||
}
|
||||
}
|
||||
|
||||
JQueryHttpClient.prototype.execute = function(obj) {
|
||||
var cb = obj.on;
|
||||
@@ -1334,9 +1346,9 @@ JQueryHttpClient.prototype.execute = function(obj) {
|
||||
else
|
||||
return cb.response(out);
|
||||
};
|
||||
|
||||
$.support.cors = true;
|
||||
return $.ajax(obj);
|
||||
|
||||
jQuery.support.cors = true;
|
||||
return jQuery.ajax(obj);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1452,16 +1464,31 @@ SwaggerAuthorizations.prototype.remove = function(name) {
|
||||
};
|
||||
|
||||
SwaggerAuthorizations.prototype.apply = function(obj, authorizations) {
|
||||
status = null;
|
||||
var status = null;
|
||||
var key;
|
||||
for (key in this.authz) {
|
||||
value = this.authz[key];
|
||||
result = value.apply(obj, authorizations);
|
||||
if (result === false)
|
||||
status = false;
|
||||
if (result === true)
|
||||
status = true;
|
||||
|
||||
if(typeof authorizations === 'undefined') {
|
||||
// apply all keys since no authorizations hash is defined
|
||||
for (key in this.authz) {
|
||||
value = this.authz[key];
|
||||
result = value.apply(obj, authorizations);
|
||||
if (result === true)
|
||||
status = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(name in authorizations) {
|
||||
for (key in this.authz) {
|
||||
if(key == name) {
|
||||
value = this.authz[key];
|
||||
result = value.apply(obj, authorizations);
|
||||
if (result === true)
|
||||
status = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user