Merge branch 'develop_2.0' of ssh://github.com/bdkosher/swagger-ui into bdkosher-develop_2.0

This commit is contained in:
Tony Tam
2015-06-03 22:23:48 -07:00
15 changed files with 40 additions and 45 deletions

View File

@@ -7,7 +7,7 @@ Handlebars.registerHelper('sanitize', function(html) {
});
Handlebars.registerHelper('renderTextParam', function(param) {
var result, type = 'text';
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;
@@ -16,11 +16,15 @@ Handlebars.registerHelper('renderTextParam', function(param) {
}
if(param.format && param.format === 'password') {
type = 'password';
type = 'password';
}
if(param.valueId) {
idAtt = ' id=\'' + param.valueId + '\'';
}
if(isArray) {
result = '<textarea class=\'body-textarea' + (param.required ? ' required' : '') + '\' name=\'' + param.name + '\'';
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 {
@@ -29,7 +33,7 @@ Handlebars.registerHelper('renderTextParam', function(param) {
parameterClass += ' required';
}
result = '<input class=\'' + parameterClass + '\' minlength=\'' + (param.required ? 1 : 0) + '\'';
result += ' name=\'' + param.name +'\' placeholder=\'' + (param.required ? '(required)' : '') + '\'';
result += ' name=\'' + param.name +'\' placeholder=\'' + (param.required ? '(required)' : '') + '\'' + idAtt;
result += ' type=\'' + type + '\' value=\'' + defaultValue + '\'/>';
}
return new Handlebars.SafeString(result);

View File

@@ -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;
}
});

View File

@@ -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;
}

View File

@@ -31,6 +31,7 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
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);
this.model.valueId = 'm' + this.model.name + Math.random();
if (this.model.allowableValues) {
this.model.isList = true;
@@ -98,4 +99,4 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
}
}
}
});
});

View File

@@ -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;
}
});