added type check

This commit is contained in:
Tony Tam
2016-10-13 15:44:06 -07:00
parent e506c5bdb8
commit 2ad57cab6b
3 changed files with 99 additions and 131 deletions

189
dist/swagger-ui.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -651,7 +651,6 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
// puts the response data in UI
showStatus: function(response) {
console.log(response.headers);
var url, content;
if (response.content === undefined) {
content = response.data;
@@ -695,9 +694,17 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
if ('Blob' in window) {
var type = contentType || 'text/html';
var a = document.createElement('a');
var href = window.URL.createObjectURL(content);
var href;
if({}.toString.apply(content) === '[object Blob]') {
href = window.URL.createObjectURL(content);
}
else {
var binaryData = [];
binaryData.push(content);
href = window.URL.createObjectURL(new Blob(binaryData, {type: type}));
}
var fileName = response.url.substr(response.url.lastIndexOf('/') + 1);
var download = [type, fileName, href].join(':');