added response check for swagger 2.0/1.2 client

This commit is contained in:
Tony Tam
2014-09-16 17:40:33 -07:00
parent 394afba3e5
commit 91822035ef
7 changed files with 39 additions and 22 deletions

19
dist/swagger-ui.js vendored
View File

@@ -1258,7 +1258,13 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
return _this.showMessage(d);
};
this.options.failure = function(d) {
return _this.onLoadFailure(d);
if (_this.api && _this.api.isValid === false) {
log("not a valid 2.0 spec, loading legacy client");
_this.api = new SwaggerApi(_this.options);
return _this.api.build();
} else {
return _this.onLoadFailure(d);
}
};
this.headerView = new HeaderView({
el: $('#header')
@@ -1284,15 +1290,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
}
this.options.url = url;
this.headerView.update(url);
if (url.indexOf('swagger.json') > 0) {
this.api = new SwaggerClient(this.options);
this.api.build();
return this.api;
} else {
this.api = new SwaggerApi(this.options);
this.api.build();
return this.api;
}
this.api = new SwaggerClient(this.options);
return this.api.build();
};
SwaggerUi.prototype.render = function() {