Skip to content

Commit 77b1b44

Browse files
committed
Merge pull request swagger-api#2112 from Oduig/master
Show property information in model for primitive types
2 parents 07ebf76 + 8328323 commit 77b1b44

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/main/javascript/view/partials/signature.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,14 @@ SwaggerUi.partials.signature = (function () {
255255
var type = schema.type || 'object';
256256
var isArray = type === 'array';
257257

258+
if (!_.isUndefined(schema.description)) {
259+
html += ': ' + '<span class="propDesc">' + schema.description + '</span>';
260+
}
261+
262+
if (schema.enum) {
263+
html += ' = <span class="propVals">[\'' + schema.enum.join('\', \'') + '\']</span>';
264+
}
265+
258266
if (isArray) {
259267
if (_.isPlainObject(schema.items) && !_.isUndefined(schema.items.type)) {
260268
type = schema.items.type;
@@ -404,16 +412,13 @@ SwaggerUi.partials.signature = (function () {
404412
var requiredClass = propertyIsRequired ? 'required' : '';
405413
var html = '<span class="propName ' + requiredClass + '">' + name + '</span> (';
406414
var model;
407-
var propDescription;
408415

409416
// Allow macro to set the default value
410417
cProperty.default = modelPropertyMacro(cProperty);
411418

412419
// Resolve the schema (Handle nested schemas)
413420
cProperty = resolveSchema(cProperty);
414421

415-
propDescription = property.description || cProperty.description;
416-
417422
// We need to handle property references to primitives (Issue 339)
418423
if (!_.isUndefined(cProperty.$ref)) {
419424
model = models[simpleRef(cProperty.$ref)];
@@ -436,14 +441,6 @@ SwaggerUi.partials.signature = (function () {
436441

437442
html += ')';
438443

439-
if (!_.isUndefined(propDescription)) {
440-
html += ': ' + '<span class="propDesc">' + propDescription + '</span>';
441-
}
442-
443-
if (cProperty.enum) {
444-
html += ' = <span class="propVals">[\'' + cProperty.enum.join('\', \'') + '\']</span>';
445-
}
446-
447444
return '<div' + (property.readOnly ? ' class="readOnly"' : '') + '>' + primitiveToOptionsHTML(cProperty, html);
448445
}).join(',</div>');
449446
}

0 commit comments

Comments
 (0)