This commit is contained in:
Tony Tam
2017-01-02 13:54:22 -07:00
3 changed files with 16 additions and 6 deletions

View File

@@ -687,6 +687,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
var pre;
var code;
var skipHighlight = false;
if (!content) {
code = $('<code />').text('no content');
pre = $('<pre class="json" />').append(code);
@@ -721,6 +722,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
var responseFilename = /filename=([^;]*);?/.exec(disposition);
if(responseFilename !== null && responseFilename.length > 1) {
download = responseFilename[1];
fileName = download;
}
}
@@ -729,6 +731,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
a.innerText = 'Download ' + fileName;
pre = $('<div/>').append(a);
skipHighlight = true;
} else {
pre = $('<pre class="json" />').append('Download headers detected but your browser does not support downloading binary via XHR (Blob).');
}
@@ -804,7 +807,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
var response_body_el = $('.response_body', $(this.el))[0];
// only highlight the response if response is less than threshold, default state is highlight response
if (opts.highlightSizeThreshold && typeof response.data !== 'undefined' && response.data.length > opts.highlightSizeThreshold) {
if (opts.highlightSizeThreshold && typeof response.data !== 'undefined' && response.data.length > opts.highlightSizeThreshold || skipHighlight) {
return response_body_el;
} else {
return hljs.highlightBlock(response_body_el);