Merge branch 'issue-2427'
This commit is contained in:
98
dist/swagger-ui.js
vendored
98
dist/swagger-ui.js
vendored
File diff suppressed because one or more lines are too long
16
dist/swagger-ui.min.js
vendored
16
dist/swagger-ui.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -83,7 +83,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Note: copied from CoffeeScript compiled file
|
// Note: copied from CoffeeScript compiled file
|
||||||
// TODO: redactor
|
// TODO: refactor
|
||||||
render: function() {
|
render: function() {
|
||||||
var a, auth, auths, code, contentTypeModel, isMethodSubmissionSupported, k, key, l, len, len1, len2, len3, len4, m, modelAuths, n, o, p, param, q, ref, ref1, ref2, ref3, ref4, ref5, responseContentTypeView, responseSignatureView, schema, schemaObj, scopeIndex, signatureModel, statusCode, successResponse, type, v, value, produces, isXML, isJSON;
|
var a, auth, auths, code, contentTypeModel, isMethodSubmissionSupported, k, key, l, len, len1, len2, len3, len4, m, modelAuths, n, o, p, param, q, ref, ref1, ref2, ref3, ref4, ref5, responseContentTypeView, responseSignatureView, schema, schemaObj, scopeIndex, signatureModel, statusCode, successResponse, type, v, value, produces, isXML, isJSON;
|
||||||
isMethodSubmissionSupported = jQuery.inArray(this.model.method, this.model.supportedSubmitMethods()) >= 0;
|
isMethodSubmissionSupported = jQuery.inArray(this.model.method, this.model.supportedSubmitMethods()) >= 0;
|
||||||
@@ -672,6 +672,17 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
contentType = contentType.split(';')[0].trim();
|
contentType = contentType.split(';')[0].trim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(contentType) {
|
||||||
|
if(typeof content === 'string') {
|
||||||
|
var arrayBuffer = new ArrayBuffer(content.length);
|
||||||
|
var uint8Array = new Uint8Array(arrayBuffer);
|
||||||
|
for (var i = 0; i < content.length; i++) {
|
||||||
|
uint8Array[i] = content.charCodeAt(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
content = new Blob([uint8Array], { type: contentType });
|
||||||
|
}
|
||||||
|
}
|
||||||
$('.response_body', $(this.el)).removeClass('json');
|
$('.response_body', $(this.el)).removeClass('json');
|
||||||
$('.response_body', $(this.el)).removeClass('xml');
|
$('.response_body', $(this.el)).removeClass('xml');
|
||||||
|
|
||||||
@@ -687,7 +698,9 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
pre = $('<pre class="json" />').append(code);
|
pre = $('<pre class="json" />').append(code);
|
||||||
|
|
||||||
// JSON
|
// JSON
|
||||||
} else if (headers['Content-Disposition'] && (/attachment/).test(headers['Content-Disposition']) ||
|
} else if (
|
||||||
|
contentType === 'application/octet-stream' ||
|
||||||
|
headers['Content-Disposition'] && (/attachment/).test(headers['Content-Disposition']) ||
|
||||||
headers['content-disposition'] && (/attachment/).test(headers['content-disposition']) ||
|
headers['content-disposition'] && (/attachment/).test(headers['content-disposition']) ||
|
||||||
headers['Content-Description'] && (/File Transfer/).test(headers['Content-Description']) ||
|
headers['Content-Description'] && (/File Transfer/).test(headers['Content-Description']) ||
|
||||||
headers['content-description'] && (/File Transfer/).test(headers['content-description'])) {
|
headers['content-description'] && (/File Transfer/).test(headers['content-description'])) {
|
||||||
|
|||||||
@@ -553,14 +553,30 @@ SwaggerUi.partials.signature = (function () {
|
|||||||
modelsToIgnore[value.name] = value;
|
modelsToIgnore[value.name] = value;
|
||||||
|
|
||||||
// Response support
|
// Response support
|
||||||
if (value.examples && _.isPlainObject(value.examples) && value.examples['application/json']) {
|
if (value.examples && _.isPlainObject(value.examples)) {
|
||||||
value.definition.example = value.examples['application/json'];
|
value = _.cloneDeep(value);
|
||||||
|
var keys = Object.keys(value.examples);
|
||||||
|
|
||||||
if (_.isString(value.definition.example)) {
|
_.forEach(keys, function(key) {
|
||||||
value.definition.example = jsyaml.safeLoad(value.definition.example);
|
if(key.indexOf('application/json') === 0) {
|
||||||
|
var example = value.examples[key];
|
||||||
|
if (_.isString(example)) {
|
||||||
|
example = jsyaml.safeLoad(example);
|
||||||
}
|
}
|
||||||
} else if (!value.definition.example) {
|
value.definition.example = example;
|
||||||
value.definition.example = value.examples;
|
return schemaToJSON(value.definition, example, modelsToIgnore, value.modelPropertyMacro);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value.examples) {
|
||||||
|
value = _.cloneDeep(value);
|
||||||
|
var example = value.examples;
|
||||||
|
if (_.isString(example)) {
|
||||||
|
example = jsyaml.safeLoad(example);
|
||||||
|
}
|
||||||
|
value.definition.example = example;
|
||||||
|
return schemaToJSON(value.definition, example, modelsToIgnore, value.modelPropertyMacro);
|
||||||
}
|
}
|
||||||
|
|
||||||
return schemaToJSON(value.definition, value.models, modelsToIgnore, value.modelPropertyMacro);
|
return schemaToJSON(value.definition, value.models, modelsToIgnore, value.modelPropertyMacro);
|
||||||
|
|||||||
Reference in New Issue
Block a user