Response headers not being displayed for either 200 or other responses #1117
This commit is contained in:
9009
dist/swagger-ui.js
vendored
9009
dist/swagger-ui.js
vendored
File diff suppressed because one or more lines are too long
22
dist/swagger-ui.min.js
vendored
22
dist/swagger-ui.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -154,7 +154,8 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
this.model.responseMessages.push({
|
this.model.responseMessages.push({
|
||||||
code: code,
|
code: code,
|
||||||
message: value.description,
|
message: value.description,
|
||||||
responseModel: schema
|
responseModel: schema,
|
||||||
|
headers: value.headers
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -169,6 +170,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
this.model.successCode = key;
|
this.model.successCode = key;
|
||||||
if (typeof value === 'object' && typeof value.createJSONSample === 'function') {
|
if (typeof value === 'object' && typeof value.createJSONSample === 'function') {
|
||||||
this.model.successDescription = value.description;
|
this.model.successDescription = value.description;
|
||||||
|
this.model.headers = this.parseResponseHeaders(value.headers);
|
||||||
signatureModel = {
|
signatureModel = {
|
||||||
sampleJSON: JSON.stringify(value.createJSONSample(), void 0, 2),
|
sampleJSON: JSON.stringify(value.createJSONSample(), void 0, 2),
|
||||||
isParam: false,
|
isParam: false,
|
||||||
@@ -241,6 +243,26 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
parseResponseHeaders: function (data) {
|
||||||
|
var HEADERS_SEPARATOR = '; ';
|
||||||
|
var headers = _.clone(data);
|
||||||
|
|
||||||
|
_.forEach(headers, function (header) {
|
||||||
|
var other = [];
|
||||||
|
_.forEach(header, function (value, key) {
|
||||||
|
var properties = ['type', 'description'];
|
||||||
|
if (properties.indexOf(key.toLowerCase()) === -1) {
|
||||||
|
other.push(key + ': ' + value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
other.join(HEADERS_SEPARATOR);
|
||||||
|
header.other = other;
|
||||||
|
});
|
||||||
|
|
||||||
|
return headers;
|
||||||
|
},
|
||||||
|
|
||||||
addParameter: function(param, consumes) {
|
addParameter: function(param, consumes) {
|
||||||
// Render a parameter
|
// Render a parameter
|
||||||
param.consumes = consumes;
|
param.consumes = consumes;
|
||||||
|
|||||||
@@ -48,6 +48,31 @@
|
|||||||
<div class="response-content-type" />
|
<div class="response-content-type" />
|
||||||
|
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if headers}}
|
||||||
|
<h4 data-sw-translate>Headers</h4>
|
||||||
|
<table class="headers">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="width: 100px; max-width: 100px" data-sw-translate>Header</th>
|
||||||
|
<th style="width: 310px; max-width: 310px" data-sw-translate>Description</th>
|
||||||
|
<th style="width: 200px; max-width: 200px" data-sw-translate>Type</th>
|
||||||
|
<th style="width: 320px; max-width: 320px" data-sw-translate>Other</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{#each headers}}
|
||||||
|
<tr>
|
||||||
|
<td>{{@key}}</td>
|
||||||
|
<td>{{this.description}}</td>
|
||||||
|
<td>{{this.type}}</td>
|
||||||
|
<td>{{this.other}}</td>
|
||||||
|
</tr>
|
||||||
|
{{/each}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
<form accept-charset='UTF-8' class='sandbox'>
|
<form accept-charset='UTF-8' class='sandbox'>
|
||||||
<div style='margin:0;padding:0;display:inline'></div>
|
<div style='margin:0;padding:0;display:inline'></div>
|
||||||
{{#if parameters}}
|
{{#if parameters}}
|
||||||
|
|||||||
Reference in New Issue
Block a user