Merge branch 'multi-value-params' of ssh://github.com/valdemon/swagger-ui into valdemon-multi-value-params
This commit is contained in:
@@ -275,6 +275,20 @@ 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 = {};
|
||||
opts = {
|
||||
@@ -295,8 +309,9 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
||||
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;
|
||||
val = this.getTextAreaValue(o);
|
||||
if ((val !== null) && jQuery.trim(val).length > 0) {
|
||||
map[o.name] = val;
|
||||
}
|
||||
}
|
||||
ref3 = form.find('select');
|
||||
@@ -666,5 +681,38 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
||||
} 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;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user