Merge pull request #2451 from swagger-api/issue-2439

added type check
This commit is contained in:
Tony Tam
2016-10-13 15:49:53 -07:00
committed by GitHub
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 // puts the response data in UI
showStatus: function(response) { showStatus: function(response) {
console.log(response.headers);
var url, content; var url, content;
if (response.content === undefined) { if (response.content === undefined) {
content = response.data; content = response.data;
@@ -695,9 +694,17 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
if ('Blob' in window) { if ('Blob' in window) {
var type = contentType || 'text/html'; var type = contentType || 'text/html';
var a = document.createElement('a'); 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 fileName = response.url.substr(response.url.lastIndexOf('/') + 1);
var download = [type, fileName, href].join(':'); var download = [type, fileName, href].join(':');