Merge remote-tracking branch 'swagger/develop_2.0' into JSONEditorMerge
Conflicts: dist/index.html dist/swagger-ui.js dist/swagger-ui.min.js src/main/html/index.html src/main/template/param.handlebars src/main/template/param_required.handlebars
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
/*global JSONEditor*/
|
||||
'use strict';
|
||||
|
||||
window.SwaggerUi = Backbone.Router.extend({
|
||||
@@ -13,6 +14,9 @@ window.SwaggerUi = Backbone.Router.extend({
|
||||
// SwaggerUi accepts all the same options as SwaggerApi
|
||||
initialize: function(options) {
|
||||
options = options || {};
|
||||
if(!options.highlightSizeThreshold) {
|
||||
options.highlightSizeThreshold = 100000;
|
||||
}
|
||||
|
||||
// Allow dom_id to be overridden
|
||||
if (options.dom_id) {
|
||||
@@ -97,7 +101,9 @@ window.SwaggerUi = Backbone.Router.extend({
|
||||
if (url && url.indexOf('http') !== 0) {
|
||||
url = this.buildUrl(window.location.href.toString(), url);
|
||||
}
|
||||
|
||||
if(this.api) {
|
||||
this.options.authorizations = this.api.clientAuthorizations.authz;
|
||||
}
|
||||
this.options.url = url;
|
||||
this.headerView.update(url);
|
||||
|
||||
@@ -180,7 +186,7 @@ window.SwaggerUi = Backbone.Router.extend({
|
||||
}
|
||||
$('#message-bar').removeClass('message-fail');
|
||||
$('#message-bar').addClass('message-success');
|
||||
$('#message-bar').html(data);
|
||||
$('#message-bar').text(data);
|
||||
},
|
||||
|
||||
// shows message in red
|
||||
@@ -191,7 +197,7 @@ window.SwaggerUi = Backbone.Router.extend({
|
||||
$('#message-bar').removeClass('message-success');
|
||||
$('#message-bar').addClass('message-fail');
|
||||
|
||||
var val = $('#message-bar').html(data);
|
||||
var val = $('#message-bar').text(data);
|
||||
|
||||
if (this.options.onFailure) {
|
||||
this.options.onFailure(data);
|
||||
@@ -205,6 +211,10 @@ window.SwaggerUi = Backbone.Router.extend({
|
||||
$('.markdown').each(function(){
|
||||
$(this).html(marked($(this).html()));
|
||||
});
|
||||
|
||||
$('.propDesc', '.model-signature .description').each(function () {
|
||||
$(this).html(marked($(this).html())).addClass('markdown');
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
@@ -263,4 +273,4 @@ window.SwaggerUi.Views = {};
|
||||
}
|
||||
}(this, function () {
|
||||
return SwaggerUi;
|
||||
}));
|
||||
}));
|
||||
|
||||
@@ -93,11 +93,13 @@ window.Docs = {
|
||||
|
||||
switch (fragments.length) {
|
||||
case 1:
|
||||
// Expand all operations for the resource and scroll to it
|
||||
var dom_id = 'resource_' + fragments[0];
|
||||
if (fragments[0].length > 0) { // prevent matching "#/"
|
||||
// Expand all operations for the resource and scroll to it
|
||||
var dom_id = 'resource_' + fragments[0];
|
||||
|
||||
Docs.expandEndpointListForResource(fragments[0]);
|
||||
$("#"+dom_id).slideto({highlight: false});
|
||||
Docs.expandEndpointListForResource(fragments[0]);
|
||||
$("#"+dom_id).slideto({highlight: false});
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
// Refer to the endpoint DOM element, e.g. #words_get_search
|
||||
|
||||
@@ -4,4 +4,37 @@ Handlebars.registerHelper('sanitize', function(html) {
|
||||
// Strip the script tags from the html, and return it as a Handlebars.SafeString
|
||||
html = html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '');
|
||||
return new Handlebars.SafeString(html);
|
||||
});
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('renderTextParam', function(param) {
|
||||
var result, type = 'text', idAtt = '';
|
||||
var isArray = param.type.toLowerCase() === 'array' || param.allowMultiple;
|
||||
var defaultValue = isArray && Array.isArray(param.default) ? param.default.join('\n') : param.default;
|
||||
|
||||
if (typeof defaultValue === 'undefined') {
|
||||
defaultValue = '';
|
||||
}
|
||||
|
||||
if(param.format && param.format === 'password') {
|
||||
type = 'password';
|
||||
}
|
||||
|
||||
if(param.valueId) {
|
||||
idAtt = ' id=\'' + param.valueId + '\'';
|
||||
}
|
||||
|
||||
if(isArray) {
|
||||
result = '<textarea class=\'body-textarea' + (param.required ? ' required' : '') + '\' name=\'' + param.name + '\'' + idAtt;
|
||||
result += ' placeholder=\'Provide multiple values in new lines' + (param.required ? ' (at least one required).' : '.') + '\'>';
|
||||
result += defaultValue + '</textarea>';
|
||||
} else {
|
||||
var parameterClass = 'parameter';
|
||||
if(param.required) {
|
||||
parameterClass += ' required';
|
||||
}
|
||||
result = '<input class=\'' + parameterClass + '\' minlength=\'' + (param.required ? 1 : 0) + '\'';
|
||||
result += ' name=\'' + param.name +'\' placeholder=\'' + (param.required ? '(required)' : '') + '\'' + idAtt;
|
||||
result += ' type=\'' + type + '\' value=\'' + defaultValue + '\'/>';
|
||||
}
|
||||
return new Handlebars.SafeString(result);
|
||||
});
|
||||
|
||||
@@ -4,10 +4,8 @@ SwaggerUi.Views.ContentTypeView = Backbone.View.extend({
|
||||
initialize: function() {},
|
||||
|
||||
render: function(){
|
||||
this.model.contentTypeId = 'ct' + Math.random();
|
||||
$(this.el).html(Handlebars.templates.content_type(this.model));
|
||||
|
||||
$('label[for=contentType]', $(this.el)).text('Response Content Type');
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
@@ -3,7 +3,6 @@
|
||||
SwaggerUi.Views.HeaderView = Backbone.View.extend({
|
||||
events: {
|
||||
'click #show-pet-store-icon' : 'showPetStore',
|
||||
'click #show-wordnik-dev-icon' : 'showWordnikDev',
|
||||
'click #explore' : 'showCustom',
|
||||
'keyup #input_baseUrl' : 'showCustomOnKeyup',
|
||||
'keyup #input_apiKey' : 'showCustomOnKeyup'
|
||||
@@ -17,12 +16,6 @@ SwaggerUi.Views.HeaderView = Backbone.View.extend({
|
||||
});
|
||||
},
|
||||
|
||||
showWordnikDev: function(){
|
||||
this.trigger('update-swagger-ui', {
|
||||
url: 'http://api.wordnik.com/v4/resources.json'
|
||||
});
|
||||
},
|
||||
|
||||
showCustomOnKeyup: function(e){
|
||||
if (e.keyCode === 13) {
|
||||
this.showCustom();
|
||||
|
||||
@@ -54,21 +54,19 @@ SwaggerUi.Views.MainView = Backbone.View.extend({
|
||||
});
|
||||
}
|
||||
|
||||
if (this.model.swaggerVersion === '2.0') {
|
||||
if ('validatorUrl' in opts.swaggerOptions) {
|
||||
|
||||
// Validator URL specified explicitly
|
||||
this.model.validatorUrl = opts.swaggerOptions.validatorUrl;
|
||||
|
||||
} else if (this.model.url.indexOf('localhost') > 0) {
|
||||
|
||||
// Localhost override
|
||||
this.model.validatorUrl = null;
|
||||
|
||||
} else {
|
||||
|
||||
// Default validator
|
||||
this.model.validatorUrl = window.location.protocol + '//online.swagger.io/validator';
|
||||
if ('validatorUrl' in opts.swaggerOptions) {
|
||||
// Validator URL specified explicitly
|
||||
this.model.validatorUrl = opts.swaggerOptions.validatorUrl;
|
||||
} else if (this.model.url.indexOf('localhost') > 0) {
|
||||
// Localhost override
|
||||
this.model.validatorUrl = null;
|
||||
} else {
|
||||
// Default validator
|
||||
if(window.location.protocol === 'https') {
|
||||
this.model.validatorUrl = 'https://online.swagger.io/validator';
|
||||
}
|
||||
else {
|
||||
this.model.validatorUrl = 'http://online.swagger.io/validator';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +141,7 @@ SwaggerUi.Views.MainView = Backbone.View.extend({
|
||||
auths: auths,
|
||||
swaggerOptions: this.options.swaggerOptions
|
||||
});
|
||||
$('#resources').append(resourceView.render().el);
|
||||
$('#resources', this.el).append(resourceView.render().el);
|
||||
},
|
||||
|
||||
clear: function(){
|
||||
|
||||
@@ -10,6 +10,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
||||
'click .toggleOperation' : 'toggleOperationContent',
|
||||
'mouseenter .api-ic' : 'mouseEnter',
|
||||
'mouseout .api-ic' : 'mouseExit',
|
||||
'dblclick .curl' : 'selectText',
|
||||
},
|
||||
|
||||
initialize: function(opts) {
|
||||
@@ -22,6 +23,24 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
||||
return this;
|
||||
},
|
||||
|
||||
selectText: function(event) {
|
||||
var doc = document,
|
||||
text = event.target.firstChild,
|
||||
range,
|
||||
selection;
|
||||
if (doc.body.createTextRange) {
|
||||
range = document.body.createTextRange();
|
||||
range.moveToElementText(text);
|
||||
range.select();
|
||||
} else if (window.getSelection) {
|
||||
selection = window.getSelection();
|
||||
range = document.createRange();
|
||||
range.selectNodeContents(text);
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
}
|
||||
},
|
||||
|
||||
mouseEnter: function(e) {
|
||||
var elem = $(this.el).find('.content');
|
||||
var x = e.pageX;
|
||||
@@ -160,6 +179,10 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
||||
signature: this.model.responseClassSignature
|
||||
};
|
||||
}
|
||||
var opts = this.options.swaggerOptions;
|
||||
if (opts.showRequestHeaders) {
|
||||
this.model.showRequestHeaders = true;
|
||||
}
|
||||
$(this.el).html(Handlebars.templates.operation(this.model));
|
||||
if (signatureModel) {
|
||||
responseSignatureView = new SwaggerUi.Views.SignatureView({
|
||||
@@ -258,7 +281,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
||||
// Note: copied from CoffeeScript compiled file
|
||||
// TODO: redactor
|
||||
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) {
|
||||
e.preventDefault();
|
||||
}
|
||||
@@ -292,36 +315,29 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
||||
error_free = false;
|
||||
}
|
||||
});
|
||||
form.find('select.required').each(function() {
|
||||
$(this).removeClass('error');
|
||||
if (this.selectedIndex === -1) {
|
||||
$(this).addClass('error');
|
||||
$(this).wiggle({
|
||||
callback: (function(_this) {
|
||||
return function() {
|
||||
$(_this).focus();
|
||||
};
|
||||
})(this)
|
||||
});
|
||||
error_free = false;
|
||||
}
|
||||
});
|
||||
if (error_free) {
|
||||
map = {};
|
||||
map = this.getInputMap(form);
|
||||
isFileUpload = this.isFileUpload(form);
|
||||
opts = {
|
||||
parent: this
|
||||
};
|
||||
isFileUpload = false;
|
||||
ref1 = form.find('input');
|
||||
for (l = 0, len = ref1.length; l < len; l++) {
|
||||
o = ref1[l];
|
||||
if ((o.value !== null) && jQuery.trim(o.value).length > 0) {
|
||||
map[o.name] = o.value;
|
||||
}
|
||||
if (o.type === 'file') {
|
||||
map[o.name] = o.files[0];
|
||||
isFileUpload = true;
|
||||
}
|
||||
}
|
||||
ref2 = form.find('textarea');
|
||||
for (m = 0, len1 = ref2.length; m < len1; m++) {
|
||||
o = ref2[m];
|
||||
if ((o.value !== null) && jQuery.trim(o.value).length > 0) {
|
||||
map[o.name] = o.value;
|
||||
}
|
||||
}
|
||||
ref3 = form.find('select');
|
||||
for (n = 0, len2 = ref3.length; n < len2; n++) {
|
||||
o = ref3[n];
|
||||
val = this.getSelectedValue(o);
|
||||
if ((val !== null) && jQuery.trim(val).length > 0) {
|
||||
map[o.name] = val;
|
||||
if (this.options.swaggerOptions) {
|
||||
for(var key in this.options.swaggerOptions) {
|
||||
opts[key] = this.options.swaggerOptions[key];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,90 +354,70 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
||||
opts.requestContentType = $('div select[name=parameterContentType]', $(this.el)).val();
|
||||
$('.response_throbber', $(this.el)).show();
|
||||
if (isFileUpload) {
|
||||
return this.handleFileUpload(map, form);
|
||||
$('.request_url', $(this.el)).html('<pre></pre>');
|
||||
$('.request_url pre', $(this.el)).text(this.invocationUrl);
|
||||
|
||||
opts.useJQuery = true;
|
||||
map.parameterContentType = 'multipart/form-data';
|
||||
|
||||
return this.model.execute(map, opts, this.showCompleteStatus, this.showErrorStatus, this);
|
||||
} else {
|
||||
return this.model['do'](map, opts, this.showCompleteStatus, this.showErrorStatus, this);
|
||||
this.map = map;
|
||||
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');
|
||||
for (l = 0, len = ref1.length; l < len; l++) {
|
||||
o = ref1[l];
|
||||
if ((o.value !== null) && jQuery.trim(o.value).length > 0) {
|
||||
map[o.name] = o.value;
|
||||
}
|
||||
if (o.type === 'file') {
|
||||
map[o.name] = o.files[0];
|
||||
}
|
||||
}
|
||||
ref2 = form.find('textarea');
|
||||
for (m = 0, len1 = ref2.length; m < len1; m++) {
|
||||
o = ref2[m];
|
||||
val = this.getTextAreaValue(o);
|
||||
if ((val !== null) && jQuery.trim(val).length > 0) {
|
||||
map[o.name] = val;
|
||||
}
|
||||
}
|
||||
ref3 = form.find('select');
|
||||
for (n = 0, len2 = ref3.length; n < len2; n++) {
|
||||
o = ref3[n];
|
||||
val = this.getSelectedValue(o);
|
||||
if ((val !== null) && jQuery.trim(val).length > 0) {
|
||||
map[o.name] = val;
|
||||
}
|
||||
}
|
||||
return map;
|
||||
},
|
||||
|
||||
isFileUpload: function (form) {
|
||||
var ref1, l, len, o;
|
||||
var isFileUpload = false;
|
||||
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) {
|
||||
parent.showCompleteStatus(response);
|
||||
},
|
||||
|
||||
// Note: This is compiled code
|
||||
// TODO: Refactor
|
||||
handleFileUpload: function(map, form) {
|
||||
var bodyParam, el, headerParams, l, len, len1, len2, len3, m, n, o, p, param, params, ref1, ref2, ref3, ref4;
|
||||
ref1 = form.serializeArray();
|
||||
for (l = 0, len = ref1.length; l < len; l++) {
|
||||
o = ref1[l];
|
||||
if ((o.value !== null) && jQuery.trim(o.value).length > 0) {
|
||||
map[o.name] = o.value;
|
||||
}
|
||||
}
|
||||
bodyParam = new FormData();
|
||||
params = 0;
|
||||
ref2 = this.model.parameters;
|
||||
for (m = 0, len1 = ref2.length; m < len1; m++) {
|
||||
param = ref2[m];
|
||||
if (param.paramType === 'form' || param['in'] === 'formData') {
|
||||
if (param.type.toLowerCase() !== 'file' && map[param.name] !== void 0) {
|
||||
bodyParam.append(param.name, map[param.name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
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"]');
|
||||
for (p = 0, len3 = ref4.length; p < len3; p++) {
|
||||
el = ref4[p];
|
||||
if (typeof el.files[0] !== 'undefined') {
|
||||
bodyParam.append($(el).attr('name'), el.files[0]);
|
||||
params += 1;
|
||||
}
|
||||
}
|
||||
this.invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), delete headerParams['Content-Type'], this.model.urlify(map, false)) : this.model.urlify(map, true);
|
||||
$('.request_url', $(this.el)).html('<pre></pre>');
|
||||
$('.request_url pre', $(this.el)).text(this.invocationUrl);
|
||||
|
||||
// TODO: don't use jQuery. Use SwaggerJS for handling the call.
|
||||
var obj = {
|
||||
type: this.model.method,
|
||||
url: this.invocationUrl,
|
||||
headers: headerParams,
|
||||
data: bodyParam,
|
||||
dataType: 'json',
|
||||
contentType: false,
|
||||
processData: false,
|
||||
error: (function(_this) {
|
||||
return function(data) {
|
||||
return _this.showErrorStatus(_this.wrap(data), _this);
|
||||
};
|
||||
})(this),
|
||||
success: (function(_this) {
|
||||
return function(data) {
|
||||
return _this.showResponse(data, _this);
|
||||
};
|
||||
})(this),
|
||||
complete: (function(_this) {
|
||||
return function(data) {
|
||||
return _this.showCompleteStatus(_this.wrap(data), _this);
|
||||
};
|
||||
})(this)
|
||||
};
|
||||
jQuery.ajax(obj);
|
||||
return false;
|
||||
// end of file-upload nastiness
|
||||
},
|
||||
// wraps a jquery response as a shred response
|
||||
|
||||
wrap: function(data) {
|
||||
var h, headerArray, headers, i, l, len, o;
|
||||
headers = {};
|
||||
@@ -576,6 +572,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
||||
url = response.request.url;
|
||||
}
|
||||
var headers = response.headers;
|
||||
content = jQuery.trim(content);
|
||||
|
||||
// if server is nice, and sends content-type back, we can use it
|
||||
var contentType = null;
|
||||
@@ -635,10 +632,10 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
||||
pre = $('<audio controls>').append($('<source>').attr('src', url).attr('type', contentType));
|
||||
|
||||
// Download
|
||||
} else if (headers['Content-Disposition'].test(/attachment/) ||
|
||||
headers['content-disposition'].test(/attachment/) ||
|
||||
headers['Content-Description'].test(/File Transfer/) ||
|
||||
headers['content-description'].test(/File Transfer/)) {
|
||||
} else if (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'])) {
|
||||
|
||||
if ('Blob' in window) {
|
||||
var type = contentType || 'text/html';
|
||||
@@ -675,23 +672,74 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
||||
$('.response', $(this.el)).slideDown();
|
||||
$('.response_hider', $(this.el)).show();
|
||||
$('.response_throbber', $(this.el)).hide();
|
||||
var response_body_el = $('.response_body', $(this.el))[0];
|
||||
|
||||
|
||||
//adds curl output
|
||||
var curlCommand = this.model.asCurl(this.map);
|
||||
curlCommand = curlCommand.replace('!', '!');
|
||||
$( '.curl', $(this.el)).html('<pre>' + curlCommand + '</pre>');
|
||||
|
||||
// only highlight the response if response is less than threshold, default state is highlight response
|
||||
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;
|
||||
} else {
|
||||
return hljs.highlightBlock(response_body_el);
|
||||
}
|
||||
},
|
||||
|
||||
toggleOperationContent: function() {
|
||||
toggleOperationContent: function (event) {
|
||||
var elem = $('#' + Docs.escapeResourceName(this.parentId + '_' + this.nickname + '_content'));
|
||||
if (elem.is(':visible')){
|
||||
event.preventDefault();
|
||||
$.bbq.pushState('#/', 2);
|
||||
Docs.collapseOperation(elem);
|
||||
} else {
|
||||
Docs.expandOperation(elem);
|
||||
}
|
||||
},
|
||||
|
||||
getTextAreaValue: function(textArea) {
|
||||
var param, parsed, result, i;
|
||||
if (textArea.value === null || jQuery.trim(textArea.value).length === 0) {
|
||||
return null;
|
||||
}
|
||||
param = this.getParamByName(textArea.name);
|
||||
if (param && param.type && param.type.toLowerCase() === 'array') {
|
||||
parsed = textArea.value.split('\n');
|
||||
result = [];
|
||||
for (i = 0; i < parsed.length; i++) {
|
||||
if (parsed[i] !== null && jQuery.trim(parsed[i]).length > 0) {
|
||||
result.push(parsed[i]);
|
||||
}
|
||||
}
|
||||
return result.length > 0 ? result : null;
|
||||
} else {
|
||||
return textArea.value;
|
||||
}
|
||||
},
|
||||
|
||||
getParamByName: function(name) {
|
||||
var i;
|
||||
if (this.model.parameters) {
|
||||
for(i = 0; i < this.model.parameters.length; i++) {
|
||||
if (this.model.parameters[i].name === name) {
|
||||
return this.model.parameters[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -4,10 +4,8 @@ SwaggerUi.Views.ParameterContentTypeView = Backbone.View.extend({
|
||||
initialize: function () {},
|
||||
|
||||
render: function(){
|
||||
this.model.parameterContentTypeId = 'pct' + Math.random();
|
||||
$(this.el).html(Handlebars.templates.parameter_content_type(this.model));
|
||||
|
||||
$('label[for=parameterContentType]', $(this.el)).text('Parameter content type:');
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
|
||||
initialize: function(){
|
||||
Handlebars.registerHelper('isArray', function(param, opts) {
|
||||
if (param.type.toLowerCase() === 'array' || param.allowMultiple) {
|
||||
opts.fn(this);
|
||||
return opts.fn(this);
|
||||
} else {
|
||||
opts.inverse(this);
|
||||
return opts.inverse(this);
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -30,7 +30,14 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
|
||||
this.model.paramType = this.model.in || this.model.paramType;
|
||||
this.model.isBody = this.model.paramType === 'body' || this.model.in === 'body';
|
||||
this.model.isFile = type && type.toLowerCase() === 'file';
|
||||
this.model.default = (this.model.default || this.model.defaultValue);
|
||||
|
||||
// Allow for default === false
|
||||
if(typeof this.model.default === 'undefined') {
|
||||
this.model.default = this.model.defaultValue;
|
||||
}
|
||||
|
||||
this.model.hasDefault = (typeof this.model.default !== 'undefined');
|
||||
this.model.valueId = 'm' + this.model.name + Math.random();
|
||||
|
||||
if (this.model.allowableValues) {
|
||||
this.model.isList = true;
|
||||
@@ -129,4 +136,4 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,10 +4,8 @@ SwaggerUi.Views.ResponseContentTypeView = Backbone.View.extend({
|
||||
initialize: function(){},
|
||||
|
||||
render: function(){
|
||||
this.model.responseContentTypeId = 'rct' + Math.random();
|
||||
$(this.el).html(Handlebars.templates.response_content_type(this.model));
|
||||
|
||||
$('label[for=responseContentType]', $(this.el)).text('Response Content Type');
|
||||
|
||||
return this;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user