Added support for toggling Model and Schema, and added support for primitives in StatusCodeView

This commit is contained in:
Shelby Sanders 2014-07-28 21:36:28 -07:00
parent 15aa4e9ae5
commit 17e8b7b919
2 changed files with 45 additions and 42 deletions

View File

@ -2039,9 +2039,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
template = this.template(); template = this.template();
$(this.el).html(template(this.model)); $(this.el).html(template(this.model));
listType = this.isListType(this.model.responseModel); listType = this.isListType(this.model.responseModel);
if (swaggerUi.api.models.hasOwnProperty(listType || this.model.responseModel)) {
isPrimitive = false; isPrimitive = false;
if ((listType !== null && swaggerUi.api.models[listType]) || swaggerUi.api.models[this.model.responseModel] !== null) { if ((listType !== null && swaggerUi.api.models[listType]) || swaggerUi.api.models[this.model.responseModel]) {
isPrimitive = false; isPrimitive = false;
} else { } else {
isPrimitive = true; isPrimitive = true;
@ -2049,8 +2048,15 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
jsonSample = null; jsonSample = null;
mockSignature = null; mockSignature = null;
if (isPrimitive) { if (isPrimitive) {
jsonSample = void 0; jsonSample = SwaggerModelProperty.prototype.toSampleValue(listType || this.model.responseModel);
mockSignature = void 0; mockSignature = listType || this.model.responseModel;
if ((listType || this.model.responseModel) === 'string') {
jsonSample = '"' + jsonSample + '"';
}
if (listType) {
jsonSample = '[' + jsonSample + ']';
mockSignature = '<span class="strong">Array of ' + mockSignature + '</span>';
}
} else if (listType) { } else if (listType) {
jsonSample = '[' + JSON.stringify(swaggerUi.api.models[listType].createJSONSample(), null, 2) + ']'; jsonSample = '[' + JSON.stringify(swaggerUi.api.models[listType].createJSONSample(), null, 2) + ']';
mockSignature = '<span class="strong">Array of </span>' + swaggerUi.api.models[listType].getMockSignature(); mockSignature = '<span class="strong">Array of </span>' + swaggerUi.api.models[listType].getMockSignature();
@ -2074,9 +2080,6 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
tagName: 'div' tagName: 'div'
}); });
$('.model-signature', this.$el).append(responseModelView.render().el); $('.model-signature', this.$el).append(responseModelView.render().el);
} else {
$('.model-signature', this.$el).html('');
}
return this; return this;
}; };
@ -2216,9 +2219,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
e.preventDefault(); e.preventDefault();
} }
$(".snippet", $(this.el)).hide(); $(".snippet", $(this.el)).hide();
$(".description", $(this.el)).show(); $('.snippet-link', $(this.el)).removeClass('selected');
$('.description-link', $(this.el)).addClass('selected'); $(".description", $(this.el)).toggle();
return $('.snippet-link', $(this.el)).removeClass('selected'); return $('.description-link', $(this.el)).toggleClass('selected');
}; };
SignatureView.prototype.switchToSnippet = function(e) { SignatureView.prototype.switchToSnippet = function(e) {
@ -2226,9 +2229,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
e.preventDefault(); e.preventDefault();
} }
$(".description", $(this.el)).hide(); $(".description", $(this.el)).hide();
$(".snippet", $(this.el)).show(); $('.description-link', $(this.el)).removeClass('selected');
$('.snippet-link', $(this.el)).addClass('selected'); $(".snippet", $(this.el)).toggle();
return $('.description-link', $(this.el)).removeClass('selected'); return $('.snippet-link', $(this.el)).toggleClass('selected');
}; };
SignatureView.prototype.snippetToTextArea = function(e) { SignatureView.prototype.snippetToTextArea = function(e) {

File diff suppressed because one or more lines are too long