Show property information in model for primitive types, similar to object types

This commit is contained in:
Guido Josquin
2016-04-22 12:06:09 +02:00
parent eb30aed1a8
commit 918aed94d6
3 changed files with 111 additions and 102 deletions

178
dist/swagger-ui.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -255,6 +255,14 @@ SwaggerUi.partials.signature = (function () {
var type = schema.type || 'object'; var type = schema.type || 'object';
var isArray = type === 'array'; var isArray = type === 'array';
if (!_.isUndefined(schema.description)) {
html += ': ' + '<span class="propDesc">' + schema.description + '</span>';
}
if (schema.enum) {
html += ' = <span class="propVals">[\'' + schema.enum.join('\', \'') + '\']</span>';
}
if (isArray) { if (isArray) {
if (_.isPlainObject(schema.items) && !_.isUndefined(schema.items.type)) { if (_.isPlainObject(schema.items) && !_.isUndefined(schema.items.type)) {
type = schema.items.type; type = schema.items.type;
@@ -404,7 +412,6 @@ SwaggerUi.partials.signature = (function () {
var requiredClass = propertyIsRequired ? 'required' : ''; var requiredClass = propertyIsRequired ? 'required' : '';
var html = '<span class="propName ' + requiredClass + '">' + name + '</span> ('; var html = '<span class="propName ' + requiredClass + '">' + name + '</span> (';
var model; var model;
var propDescription;
// Allow macro to set the default value // Allow macro to set the default value
cProperty.default = modelPropertyMacro(cProperty); cProperty.default = modelPropertyMacro(cProperty);
@@ -412,8 +419,6 @@ SwaggerUi.partials.signature = (function () {
// Resolve the schema (Handle nested schemas) // Resolve the schema (Handle nested schemas)
cProperty = resolveSchema(cProperty); cProperty = resolveSchema(cProperty);
propDescription = property.description || cProperty.description;
// We need to handle property references to primitives (Issue 339) // We need to handle property references to primitives (Issue 339)
if (!_.isUndefined(cProperty.$ref)) { if (!_.isUndefined(cProperty.$ref)) {
model = models[simpleRef(cProperty.$ref)]; model = models[simpleRef(cProperty.$ref)];
@@ -436,14 +441,6 @@ SwaggerUi.partials.signature = (function () {
html += ')'; html += ')';
if (!_.isUndefined(propDescription)) {
html += ': ' + '<span class="propDesc">' + propDescription + '</span>';
}
if (cProperty.enum) {
html += ' = <span class="propVals">[\'' + cProperty.enum.join('\', \'') + '\']</span>';
}
return '<div' + (property.readOnly ? ' class="readOnly"' : '') + '>' + primitiveToOptionsHTML(cProperty, html); return '<div' + (property.readOnly ? ' class="readOnly"' : '') + '>' + primitiveToOptionsHTML(cProperty, html);
}).join(',</div>'); }).join(',</div>');
} }