This commit is contained in:
Tony Tam
2015-01-22 22:48:14 -08:00
parent 5a023c1b45
commit a75c9c191a
5 changed files with 308 additions and 260 deletions

View File

@@ -1,8 +1,9 @@
// swagger-client.js
// version 2.1.0-alpha.5
/**
* Array Model
**/
* swagger-client - swagger.js is a javascript client for use with swaggering APIs.
* @version v2.1.0-alpha.5
* @link http://swagger.io
* @license apache 2.0
*/
var ArrayModel = function(definition) {
this.name = "name";
this.definition = definition || {};
@@ -57,6 +58,7 @@ ArrayModel.prototype.getMockSignature = function(modelsToIgnore) {
}
};
/**
* SwaggerAuthorizations applys the correct authorization to an operation being executed
*/
@@ -157,7 +159,8 @@ PasswordAuthorization.prototype.apply = function(obj, authorizations) {
var base64encoder = this._btoa;
obj.headers["Authorization"] = "Basic " + base64encoder(this.username + ":" + this.password);
return true;
};var __bind = function(fn, me){
};
var __bind = function(fn, me){
return function(){
return fn.apply(me, arguments);
};
@@ -238,6 +241,7 @@ Object.keys = Object.keys || (function () {
return result;
};
})();
/**
* PrimitiveModel
**/
@@ -289,7 +293,8 @@ PrimitiveModel.prototype.getMockSignature = function(modelsToIgnore) {
}
}
return returnVal;
};var SwaggerClient = function(url, options) {
};
var SwaggerClient = function(url, options) {
this.isBuilt = false;
this.url = null;
this.debug = false;
@@ -316,6 +321,7 @@ PrimitiveModel.prototype.getMockSignature = function(modelsToIgnore) {
if (typeof options.useJQuery === 'boolean')
this.useJQuery = options.useJQuery;
this.supportedSubmitMethods = options.supportedSubmitMethods || [];
this.failure = options.failure != null ? options.failure : function() {};
this.progress = options.progress != null ? options.progress : function() {};
this.spec = options.spec;
@@ -763,7 +769,7 @@ Operation.prototype.supportHeaderParams = function () {
};
Operation.prototype.supportedSubmitMethods = function () {
return this.resource.api.supportedSubmitMethods;
return this.parent.supportedSubmitMethods;
};
Operation.prototype.getHeaderParams = function (args) {
@@ -1111,11 +1117,8 @@ Operation.prototype.encodeQueryCollection = function(type, name, value) {
return encoded;
}
/**
* TODO this encoding needs to be changed
**/
Operation.prototype.encodeQueryParam = function(arg) {
return escape(arg);
return encodeURIComponent(arg);
}
/**
@@ -1378,6 +1381,7 @@ e.PasswordAuthorization = PasswordAuthorization;
e.CookieAuthorization = CookieAuthorization;
e.SwaggerClient = SwaggerClient;
e.Operation = Operation;
/**
* SwaggerHttp is a wrapper for executing requests
*/
@@ -1389,6 +1393,10 @@ SwaggerHttp.prototype.execute = function(obj) {
else
this.useJQuery = this.isIE8();
if(obj && typeof obj.body === 'object') {
obj.body = JSON.stringify(obj.body);
}
if(this.useJQuery)
return new JQueryHttpClient().execute(obj);
else
@@ -1563,7 +1571,8 @@ ShredHttpClient.prototype.execute = function(obj) {
data: response.content.data
};
var contentType = (response._headers["content-type"]||response._headers["Content-Type"]||null)
var headers = response._headers.normalized || response._headers;
var contentType = (headers["content-type"]||headers["Content-Type"]||null)
if(contentType != null) {
if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) {