updated for #849

This commit is contained in:
Tony Tam
2015-01-29 22:16:07 -08:00
parent 8962e220f1
commit a969680904
5 changed files with 42 additions and 32 deletions

View File

@@ -1547,13 +1547,13 @@ var SwaggerClient = function(url, options) {
this.models = {};
options = (options||{});
if (url)
if (url.url) options = url;
else this.url = url;
else options = url;
if (typeof options.url === 'string')
if(typeof url === 'string')
this.url = url;
else if(typeof url === 'object') {
options = url;
this.url = options.url;
}
if (typeof options.success === 'function')
this.success = options.success;
@@ -1636,9 +1636,14 @@ SwaggerClient.prototype.buildFromSpec = function(response) {
// legacy support
this.authSchemes = response.securityDefinitions;
var location = this.parseUri(this.url);
var location;
if(typeof this.url === 'string') {
location = this.parseUri(this.url);
}
if(typeof this.schemes === 'undefined' || this.schemes.length === 0) {
this.scheme = location.scheme;
this.scheme = location.scheme || 'http';
}
else {
this.scheme = this.schemes[0];