Merge branch 'nprdm-feature/request_headers' into develop_2.0
This commit is contained in:
@@ -96,8 +96,9 @@ operationsSorter | Apply a sort to the operation list of each API. It can be 'al
|
|||||||
onComplete | This is a callback function parameter which can be passed to be notified of when SwaggerUI has completed rendering successfully.
|
onComplete | This is a callback function parameter which can be passed to be notified of when SwaggerUI has completed rendering successfully.
|
||||||
onFailure | This is a callback function parameter which can be passed to be notified of when SwaggerUI encountered a failure was unable to render.
|
onFailure | This is a callback function parameter which can be passed to be notified of when SwaggerUI encountered a failure was unable to render.
|
||||||
highlightSizeThreshold | Any size response below this threshold will be highlighted syntactically, attempting to highlight large responses can lead to browser hangs, not including a threshold will default to highlight all returned responses.
|
highlightSizeThreshold | Any size response below this threshold will be highlighted syntactically, attempting to highlight large responses can lead to browser hangs, not including a threshold will default to highlight all returned responses.
|
||||||
supportedSubmitMethods | An array of of the HTTP operations that will have the 'Try it out!` option. An empty array disables all operations. This does not filter the operations from the display.
|
supportedSubmitMethods | An array of of the HTTP operations that will have the 'Try it out!' option. An empty array disables all operations. This does not filter the operations from the display.
|
||||||
oauth2RedirectUrl | OAuth redirect URL
|
oauth2RedirectUrl | OAuth redirect URL
|
||||||
|
showRequestHeaders | Whether or not to show the headers that were sent when making a request via the 'Try it out!' option. Defaults to `false`.
|
||||||
|
|
||||||
* All other parameters are explained in greater detail below
|
* All other parameters are explained in greater detail below
|
||||||
|
|
||||||
|
|||||||
3
dist/index.html
vendored
3
dist/index.html
vendored
@@ -52,7 +52,8 @@
|
|||||||
log("Unable to Load SwaggerUI");
|
log("Unable to Load SwaggerUI");
|
||||||
},
|
},
|
||||||
docExpansion: "none",
|
docExpansion: "none",
|
||||||
apisSorter: "alpha"
|
apisSorter: "alpha",
|
||||||
|
showRequestHeaders: false
|
||||||
});
|
});
|
||||||
|
|
||||||
function addApiKeyAuthorization(){
|
function addApiKeyAuthorization(){
|
||||||
|
|||||||
78
dist/swagger-ui.js
vendored
78
dist/swagger-ui.js
vendored
@@ -408,6 +408,8 @@ this["Handlebars"]["templates"]["operation"] = Handlebars.template({"1":function
|
|||||||
return "";
|
return "";
|
||||||
},"24":function(depth0,helpers,partials,data) {
|
},"24":function(depth0,helpers,partials,data) {
|
||||||
return " <div class='sandbox_header'>\n <input class='submit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <span class='response_throbber' style='display:none'></span>\n </div>\n";
|
return " <div class='sandbox_header'>\n <input class='submit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <span class='response_throbber' style='display:none'></span>\n </div>\n";
|
||||||
|
},"26":function(depth0,helpers,partials,data) {
|
||||||
|
return " <h4>Request Headers</h4>\n <div class='block request_headers'></div>\n";
|
||||||
},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
|
},"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
|
||||||
var stack1, helper, options, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, blockHelperMissing=helpers.blockHelperMissing, buffer = "\n <ul class='operations' >\n <li class='"
|
var stack1, helper, options, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, blockHelperMissing=helpers.blockHelperMissing, buffer = "\n <ul class='operations' >\n <li class='"
|
||||||
+ escapeExpression(((helper = (helper = helpers.method || (depth0 != null ? depth0.method : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"method","hash":{},"data":data}) : helper)))
|
+ escapeExpression(((helper = (helper = helpers.method || (depth0 != null ? depth0.method : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"method","hash":{},"data":data}) : helper)))
|
||||||
@@ -469,7 +471,10 @@ this["Handlebars"]["templates"]["operation"] = Handlebars.template({"1":function
|
|||||||
if (stack1 != null) { buffer += stack1; }
|
if (stack1 != null) { buffer += stack1; }
|
||||||
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isReadOnly : depth0), {"name":"if","hash":{},"fn":this.program(22, data),"inverse":this.program(24, data),"data":data});
|
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.isReadOnly : depth0), {"name":"if","hash":{},"fn":this.program(22, data),"inverse":this.program(24, data),"data":data});
|
||||||
if (stack1 != null) { buffer += stack1; }
|
if (stack1 != null) { buffer += stack1; }
|
||||||
return buffer + " </form>\n <div class='response' style='display:none'>\n <h4>Request URL</h4>\n <div class='block request_url'></div>\n <h4>Response Body</h4>\n <div class='block response_body'></div>\n <h4>Response Code</h4>\n <div class='block response_code'></div>\n <h4>Response Headers</h4>\n <div class='block response_headers'></div>\n </div>\n </div>\n </li>\n </ul>\n";
|
buffer += " </form>\n <div class='response' style='display:none'>\n <h4>Request URL</h4>\n <div class='block request_url'></div>\n";
|
||||||
|
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.showRequestHeaders : depth0), {"name":"if","hash":{},"fn":this.program(26, data),"inverse":this.noop,"data":data});
|
||||||
|
if (stack1 != null) { buffer += stack1; }
|
||||||
|
return buffer + " <h4>Response Body</h4>\n <div class='block response_body'></div>\n <h4>Response Code</h4>\n <div class='block response_code'></div>\n <h4>Response Headers</h4>\n <div class='block response_headers'></div>\n </div>\n </div>\n </li>\n </ul>\n";
|
||||||
},"useData":true});
|
},"useData":true});
|
||||||
this["Handlebars"]["templates"]["param_list"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
|
this["Handlebars"]["templates"]["param_list"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
|
||||||
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
|
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
|
||||||
@@ -1574,6 +1579,10 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
signature: this.model.responseClassSignature
|
signature: this.model.responseClassSignature
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
var opts = this.options.swaggerOptions;
|
||||||
|
if (opts.showRequestHeaders) {
|
||||||
|
this.model.showRequestHeaders = true;
|
||||||
|
}
|
||||||
$(this.el).html(Handlebars.templates.operation(this.model));
|
$(this.el).html(Handlebars.templates.operation(this.model));
|
||||||
if (signatureModel) {
|
if (signatureModel) {
|
||||||
responseSignatureView = new SwaggerUi.Views.SignatureView({
|
responseSignatureView = new SwaggerUi.Views.SignatureView({
|
||||||
@@ -1655,7 +1664,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
// Note: copied from CoffeeScript compiled file
|
// Note: copied from CoffeeScript compiled file
|
||||||
// TODO: redactor
|
// TODO: redactor
|
||||||
submitOperation: function(e) {
|
submitOperation: function(e) {
|
||||||
var error_free, form, isFileUpload, l, len, len1, len2, m, map, n, o, opts, ref1, ref2, ref3, val;
|
var error_free, form, isFileUpload, map, opts;
|
||||||
if (e !== null) {
|
if (e !== null) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
@@ -1704,16 +1713,30 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (error_free) {
|
if (error_free) {
|
||||||
map = {};
|
map = this.getInputMap(form);
|
||||||
|
isFileUpload = this.isFileUpload(form);
|
||||||
opts = {
|
opts = {
|
||||||
parent: this
|
parent: this
|
||||||
};
|
};
|
||||||
if(this.options.swaggerOptions) {
|
if (this.options.swaggerOptions) {
|
||||||
for(var key in this.options.swaggerOptions) {
|
for(var key in this.options.swaggerOptions) {
|
||||||
opts[key] = this.options.swaggerOptions[key];
|
opts[key] = this.options.swaggerOptions[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isFileUpload = false;
|
opts.responseContentType = $('div select[name=responseContentType]', $(this.el)).val();
|
||||||
|
opts.requestContentType = $('div select[name=parameterContentType]', $(this.el)).val();
|
||||||
|
$('.response_throbber', $(this.el)).show();
|
||||||
|
if (isFileUpload) {
|
||||||
|
return this.handleFileUpload(map, form);
|
||||||
|
} else {
|
||||||
|
return this.model.execute(map, opts, this.showCompleteStatus, this.showErrorStatus, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getInputMap: function (form) {
|
||||||
|
var map, ref1, l, len, o, ref2, m, len1, val, ref3, n, len2;
|
||||||
|
map = {};
|
||||||
ref1 = form.find('input');
|
ref1 = form.find('input');
|
||||||
for (l = 0, len = ref1.length; l < len; l++) {
|
for (l = 0, len = ref1.length; l < len; l++) {
|
||||||
o = ref1[l];
|
o = ref1[l];
|
||||||
@@ -1722,7 +1745,6 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
}
|
}
|
||||||
if (o.type === 'file') {
|
if (o.type === 'file') {
|
||||||
map[o.name] = o.files[0];
|
map[o.name] = o.files[0];
|
||||||
isFileUpload = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ref2 = form.find('textarea');
|
ref2 = form.find('textarea');
|
||||||
@@ -1741,15 +1763,20 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
map[o.name] = val;
|
map[o.name] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
opts.responseContentType = $('div select[name=responseContentType]', $(this.el)).val();
|
return map;
|
||||||
opts.requestContentType = $('div select[name=parameterContentType]', $(this.el)).val();
|
},
|
||||||
$('.response_throbber', $(this.el)).show();
|
|
||||||
if (isFileUpload) {
|
isFileUpload: function (form) {
|
||||||
return this.handleFileUpload(map, form);
|
var ref1, l, len, o;
|
||||||
} else {
|
var isFileUpload = false;
|
||||||
return this.model.execute(map, opts, this.showCompleteStatus, this.showErrorStatus, this);
|
ref1 = form.find('input');
|
||||||
|
for (l = 0, len = ref1.length; l < len; l++) {
|
||||||
|
o = ref1[l];
|
||||||
|
if (o.type === 'file') {
|
||||||
|
isFileUpload = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return isFileUpload;
|
||||||
},
|
},
|
||||||
|
|
||||||
success: function(response, parent) {
|
success: function(response, parent) {
|
||||||
@@ -1759,7 +1786,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
// Note: This is compiled code
|
// Note: This is compiled code
|
||||||
// TODO: Refactor
|
// TODO: Refactor
|
||||||
handleFileUpload: function(map, form) {
|
handleFileUpload: function(map, form) {
|
||||||
var bodyParam, el, headerParams, l, len, len1, len2, len3, m, n, o, p, param, params, ref1, ref2, ref3, ref4;
|
var bodyParam, el, headerParams, l, len, len1, len3, m, o, p, param, params, ref1, ref2, ref4;
|
||||||
ref1 = form.serializeArray();
|
ref1 = form.serializeArray();
|
||||||
for (l = 0, len = ref1.length; l < len; l++) {
|
for (l = 0, len = ref1.length; l < len; l++) {
|
||||||
o = ref1[l];
|
o = ref1[l];
|
||||||
@@ -1778,14 +1805,6 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
headerParams = {};
|
|
||||||
ref3 = this.model.parameters;
|
|
||||||
for (n = 0, len2 = ref3.length; n < len2; n++) {
|
|
||||||
param = ref3[n];
|
|
||||||
if (param.paramType === 'header') {
|
|
||||||
headerParams[param.name] = map[param.name];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ref4 = form.find('input[type~="file"]');
|
ref4 = form.find('input[type~="file"]');
|
||||||
for (p = 0, len3 = ref4.length; p < len3; p++) {
|
for (p = 0, len3 = ref4.length; p < len3; p++) {
|
||||||
el = ref4[p];
|
el = ref4[p];
|
||||||
@@ -2083,11 +2102,20 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
$('.response', $(this.el)).slideDown();
|
$('.response', $(this.el)).slideDown();
|
||||||
$('.response_hider', $(this.el)).show();
|
$('.response_hider', $(this.el)).show();
|
||||||
$('.response_throbber', $(this.el)).hide();
|
$('.response_throbber', $(this.el)).hide();
|
||||||
var response_body_el = $('.response_body', $(this.el))[0];
|
|
||||||
|
|
||||||
// only highlight the response if response is less than threshold, default state is highlight response
|
|
||||||
var opts = this.options.swaggerOptions;
|
var opts = this.options.swaggerOptions;
|
||||||
if (opts.highlightSizeThreshold && response.data.length > opts.highlightSizeThreshold) {
|
|
||||||
|
if (opts.showRequestHeaders) {
|
||||||
|
var form = $('.sandbox', $(this.el)),
|
||||||
|
map = this.getInputMap(form),
|
||||||
|
requestHeaders = this.model.getHeaderParams(map);
|
||||||
|
delete requestHeaders['Content-Type'];
|
||||||
|
$('.request_headers', $(this.el)).html('<pre>' + _.escape(JSON.stringify(requestHeaders, null, ' ')).replace(/\n/g, '<br>') + '</pre>');
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
return response_body_el;
|
return response_body_el;
|
||||||
} else {
|
} else {
|
||||||
return hljs.highlightBlock(response_body_el);
|
return hljs.highlightBlock(response_body_el);
|
||||||
|
|||||||
6
dist/swagger-ui.min.js
vendored
6
dist/swagger-ui.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -52,7 +52,8 @@
|
|||||||
log("Unable to Load SwaggerUI");
|
log("Unable to Load SwaggerUI");
|
||||||
},
|
},
|
||||||
docExpansion: "none",
|
docExpansion: "none",
|
||||||
apisSorter: "alpha"
|
apisSorter: "alpha",
|
||||||
|
showRequestHeaders: false
|
||||||
});
|
});
|
||||||
|
|
||||||
function addApiKeyAuthorization(){
|
function addApiKeyAuthorization(){
|
||||||
|
|||||||
@@ -160,6 +160,10 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
signature: this.model.responseClassSignature
|
signature: this.model.responseClassSignature
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
var opts = this.options.swaggerOptions;
|
||||||
|
if (opts.showRequestHeaders) {
|
||||||
|
this.model.showRequestHeaders = true;
|
||||||
|
}
|
||||||
$(this.el).html(Handlebars.templates.operation(this.model));
|
$(this.el).html(Handlebars.templates.operation(this.model));
|
||||||
if (signatureModel) {
|
if (signatureModel) {
|
||||||
responseSignatureView = new SwaggerUi.Views.SignatureView({
|
responseSignatureView = new SwaggerUi.Views.SignatureView({
|
||||||
@@ -241,7 +245,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
// Note: copied from CoffeeScript compiled file
|
// Note: copied from CoffeeScript compiled file
|
||||||
// TODO: redactor
|
// TODO: redactor
|
||||||
submitOperation: function(e) {
|
submitOperation: function(e) {
|
||||||
var error_free, form, isFileUpload, l, len, len1, len2, m, map, n, o, opts, ref1, ref2, ref3, val;
|
var error_free, form, isFileUpload, map, opts;
|
||||||
if (e !== null) {
|
if (e !== null) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
@@ -290,16 +294,30 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (error_free) {
|
if (error_free) {
|
||||||
map = {};
|
map = this.getInputMap(form);
|
||||||
|
isFileUpload = this.isFileUpload(form);
|
||||||
opts = {
|
opts = {
|
||||||
parent: this
|
parent: this
|
||||||
};
|
};
|
||||||
if(this.options.swaggerOptions) {
|
if (this.options.swaggerOptions) {
|
||||||
for(var key in this.options.swaggerOptions) {
|
for(var key in this.options.swaggerOptions) {
|
||||||
opts[key] = this.options.swaggerOptions[key];
|
opts[key] = this.options.swaggerOptions[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isFileUpload = false;
|
opts.responseContentType = $('div select[name=responseContentType]', $(this.el)).val();
|
||||||
|
opts.requestContentType = $('div select[name=parameterContentType]', $(this.el)).val();
|
||||||
|
$('.response_throbber', $(this.el)).show();
|
||||||
|
if (isFileUpload) {
|
||||||
|
return this.handleFileUpload(map, form);
|
||||||
|
} else {
|
||||||
|
return this.model.execute(map, opts, this.showCompleteStatus, this.showErrorStatus, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
getInputMap: function (form) {
|
||||||
|
var map, ref1, l, len, o, ref2, m, len1, val, ref3, n, len2;
|
||||||
|
map = {};
|
||||||
ref1 = form.find('input');
|
ref1 = form.find('input');
|
||||||
for (l = 0, len = ref1.length; l < len; l++) {
|
for (l = 0, len = ref1.length; l < len; l++) {
|
||||||
o = ref1[l];
|
o = ref1[l];
|
||||||
@@ -308,7 +326,6 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
}
|
}
|
||||||
if (o.type === 'file') {
|
if (o.type === 'file') {
|
||||||
map[o.name] = o.files[0];
|
map[o.name] = o.files[0];
|
||||||
isFileUpload = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ref2 = form.find('textarea');
|
ref2 = form.find('textarea');
|
||||||
@@ -327,15 +344,20 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
map[o.name] = val;
|
map[o.name] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
opts.responseContentType = $('div select[name=responseContentType]', $(this.el)).val();
|
return map;
|
||||||
opts.requestContentType = $('div select[name=parameterContentType]', $(this.el)).val();
|
},
|
||||||
$('.response_throbber', $(this.el)).show();
|
|
||||||
if (isFileUpload) {
|
isFileUpload: function (form) {
|
||||||
return this.handleFileUpload(map, form);
|
var ref1, l, len, o;
|
||||||
} else {
|
var isFileUpload = false;
|
||||||
return this.model.execute(map, opts, this.showCompleteStatus, this.showErrorStatus, this);
|
ref1 = form.find('input');
|
||||||
|
for (l = 0, len = ref1.length; l < len; l++) {
|
||||||
|
o = ref1[l];
|
||||||
|
if (o.type === 'file') {
|
||||||
|
isFileUpload = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return isFileUpload;
|
||||||
},
|
},
|
||||||
|
|
||||||
success: function(response, parent) {
|
success: function(response, parent) {
|
||||||
@@ -345,7 +367,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
// Note: This is compiled code
|
// Note: This is compiled code
|
||||||
// TODO: Refactor
|
// TODO: Refactor
|
||||||
handleFileUpload: function(map, form) {
|
handleFileUpload: function(map, form) {
|
||||||
var bodyParam, el, headerParams, l, len, len1, len2, len3, m, n, o, p, param, params, ref1, ref2, ref3, ref4;
|
var bodyParam, el, headerParams, l, len, len1, len3, m, o, p, param, params, ref1, ref2, ref4;
|
||||||
ref1 = form.serializeArray();
|
ref1 = form.serializeArray();
|
||||||
for (l = 0, len = ref1.length; l < len; l++) {
|
for (l = 0, len = ref1.length; l < len; l++) {
|
||||||
o = ref1[l];
|
o = ref1[l];
|
||||||
@@ -364,14 +386,6 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
headerParams = {};
|
|
||||||
ref3 = this.model.parameters;
|
|
||||||
for (n = 0, len2 = ref3.length; n < len2; n++) {
|
|
||||||
param = ref3[n];
|
|
||||||
if (param.paramType === 'header') {
|
|
||||||
headerParams[param.name] = map[param.name];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ref4 = form.find('input[type~="file"]');
|
ref4 = form.find('input[type~="file"]');
|
||||||
for (p = 0, len3 = ref4.length; p < len3; p++) {
|
for (p = 0, len3 = ref4.length; p < len3; p++) {
|
||||||
el = ref4[p];
|
el = ref4[p];
|
||||||
@@ -669,11 +683,20 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
$('.response', $(this.el)).slideDown();
|
$('.response', $(this.el)).slideDown();
|
||||||
$('.response_hider', $(this.el)).show();
|
$('.response_hider', $(this.el)).show();
|
||||||
$('.response_throbber', $(this.el)).hide();
|
$('.response_throbber', $(this.el)).hide();
|
||||||
var response_body_el = $('.response_body', $(this.el))[0];
|
|
||||||
|
|
||||||
// only highlight the response if response is less than threshold, default state is highlight response
|
|
||||||
var opts = this.options.swaggerOptions;
|
var opts = this.options.swaggerOptions;
|
||||||
if (opts.highlightSizeThreshold && response.data.length > opts.highlightSizeThreshold) {
|
|
||||||
|
if (opts.showRequestHeaders) {
|
||||||
|
var form = $('.sandbox', $(this.el)),
|
||||||
|
map = this.getInputMap(form),
|
||||||
|
requestHeaders = this.model.getHeaderParams(map);
|
||||||
|
delete requestHeaders['Content-Type'];
|
||||||
|
$('.request_headers', $(this.el)).html('<pre>' + _.escape(JSON.stringify(requestHeaders, null, ' ')).replace(/\n/g, '<br>') + '</pre>');
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
return response_body_el;
|
return response_body_el;
|
||||||
} else {
|
} else {
|
||||||
return hljs.highlightBlock(response_body_el);
|
return hljs.highlightBlock(response_body_el);
|
||||||
|
|||||||
@@ -94,6 +94,10 @@
|
|||||||
<div class='response' style='display:none'>
|
<div class='response' style='display:none'>
|
||||||
<h4>Request URL</h4>
|
<h4>Request URL</h4>
|
||||||
<div class='block request_url'></div>
|
<div class='block request_url'></div>
|
||||||
|
{{#if showRequestHeaders}}
|
||||||
|
<h4>Request Headers</h4>
|
||||||
|
<div class='block request_headers'></div>
|
||||||
|
{{/if}}
|
||||||
<h4>Response Body</h4>
|
<h4>Response Body</h4>
|
||||||
<div class='block response_body'></div>
|
<div class='block response_body'></div>
|
||||||
<h4>Response Code</h4>
|
<h4>Response Code</h4>
|
||||||
|
|||||||
Reference in New Issue
Block a user