Added support for toggling Model and Schema, and added support for primitives in StatusCodeView
This commit is contained in:
parent
15aa4e9ae5
commit
17e8b7b919
|
@ -2039,9 +2039,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
template = this.template();
|
||||
$(this.el).html(template(this.model));
|
||||
listType = this.isListType(this.model.responseModel);
|
||||
if (swaggerUi.api.models.hasOwnProperty(listType || this.model.responseModel)) {
|
||||
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;
|
||||
} else {
|
||||
isPrimitive = true;
|
||||
|
@ -2049,8 +2048,15 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
jsonSample = null;
|
||||
mockSignature = null;
|
||||
if (isPrimitive) {
|
||||
jsonSample = void 0;
|
||||
mockSignature = void 0;
|
||||
jsonSample = SwaggerModelProperty.prototype.toSampleValue(listType || this.model.responseModel);
|
||||
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) {
|
||||
jsonSample = '[' + JSON.stringify(swaggerUi.api.models[listType].createJSONSample(), null, 2) + ']';
|
||||
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'
|
||||
});
|
||||
$('.model-signature', this.$el).append(responseModelView.render().el);
|
||||
} else {
|
||||
$('.model-signature', this.$el).html('');
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
|
@ -2216,9 +2219,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
e.preventDefault();
|
||||
}
|
||||
$(".snippet", $(this.el)).hide();
|
||||
$(".description", $(this.el)).show();
|
||||
$('.description-link', $(this.el)).addClass('selected');
|
||||
return $('.snippet-link', $(this.el)).removeClass('selected');
|
||||
$('.snippet-link', $(this.el)).removeClass('selected');
|
||||
$(".description", $(this.el)).toggle();
|
||||
return $('.description-link', $(this.el)).toggleClass('selected');
|
||||
};
|
||||
|
||||
SignatureView.prototype.switchToSnippet = function(e) {
|
||||
|
@ -2226,9 +2229,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||
e.preventDefault();
|
||||
}
|
||||
$(".description", $(this.el)).hide();
|
||||
$(".snippet", $(this.el)).show();
|
||||
$('.snippet-link', $(this.el)).addClass('selected');
|
||||
return $('.description-link', $(this.el)).removeClass('selected');
|
||||
$('.description-link', $(this.el)).removeClass('selected');
|
||||
$(".snippet", $(this.el)).toggle();
|
||||
return $('.snippet-link', $(this.el)).toggleClass('selected');
|
||||
};
|
||||
|
||||
SignatureView.prototype.snippetToTextArea = function(e) {
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue