updated swagger-js

This commit is contained in:
Tony Tam
2014-09-14 14:06:31 -07:00
parent 66718f23dd
commit 0395bf3eb3
2 changed files with 32 additions and 15 deletions

View File

@@ -216,7 +216,7 @@ SwaggerClient.prototype.build = function() {
url: this.url,
method: "get",
headers: {
accept: "application/json"
accept: "application/json, */*"
},
on: {
error: function(response) {
@@ -260,6 +260,11 @@ SwaggerClient.prototype.buildFromSpec = function(response) {
this.produces = response.produces;
this.authSchemes = response.authorizations;
if(typeof this.host === 'undefined' || this.host === '') {
var location = this.parseUri(this.url);
this.host = location.host;
}
this.definitions = response.definitions;
var key;
for(key in this.definitions) {
@@ -330,6 +335,16 @@ SwaggerClient.prototype.buildFromSpec = function(response) {
return this;
}
SwaggerClient.prototype.parseUri = function(uri) {
var urlParseRE = /^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;
var parts = urlParseRE.exec(uri);
return {
scheme: parts[4].replace(':',''),
host: parts[11],
path: parts[15]
};
}
SwaggerClient.prototype.help = function() {
var i;
log('operations for the "' + this.label + '" tag');