Use filename from content-disposition in a download link
This commit is contained in:
8
dist/swagger-ui.js
vendored
8
dist/swagger-ui.js
vendored
@@ -23499,6 +23499,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);
|
||||
@@ -23531,6 +23532,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
||||
var responseFilename = /filename=([^;]*);?/.exec(disposition);
|
||||
if(responseFilename !== null && responseFilename.length > 1) {
|
||||
download = responseFilename[1];
|
||||
fileName = download;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23539,6 +23541,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).');
|
||||
}
|
||||
@@ -23614,7 +23617,10 @@ 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);
|
||||
|
||||
2
dist/swagger-ui.min.js
vendored
2
dist/swagger-ui.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -682,6 +682,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);
|
||||
@@ -714,6 +715,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
||||
var responseFilename = /filename=([^;]*);?/.exec(disposition);
|
||||
if(responseFilename !== null && responseFilename.length > 1) {
|
||||
download = responseFilename[1];
|
||||
fileName = download;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -722,6 +724,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).');
|
||||
}
|
||||
@@ -797,7 +800,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);
|
||||
|
||||
Reference in New Issue
Block a user