in source/nodejs/marked-schema/lib/generateMarkdown.js [252:361]
function createPropertyDetails(property, headerLevel, knownTypes, autoLink) {
var md = '';
var summary = getPropertySummary(property, knownTypes, autoLink);
var type = summary.type;
md += style.getHeaderMarkdown(property.name, headerLevel) + (summary.required === 'Yes' ? style.requiredIcon : '') + '\n\n';
// TODO: Add plugin point for custom JSON schema properties like gltf_*
var detailedDescription = autoLinkDescription(property.gltf_detailedDescription, knownTypes, autoLink);
if (defined(detailedDescription)) {
md += detailedDescription + '\n';
} else if (defined(summary.description)) {
md += summary.description + '\n';
}
md += '* ' + style.propertyDetails('Type') + ': ' + summary.formattedType + '\n';
var uniqueItems = property.uniqueItems;
if (defined(uniqueItems) && uniqueItems) {
md += ' * Each element in the array must be unique.\n';
}
// TODO: items is a full schema
var items = property.items;
if (defined(items)) {
var itemsExclusiveMinimum = (defined(items.exclusiveMinimum) && items.exclusiveMinimum);
var minString = itemsExclusiveMinimum ? 'greater than' : 'greater than or equal to';
var itemsExclusiveMaximum = (defined(items.exclusiveMaximum) && items.exclusiveMaximum);
var maxString = itemsExclusiveMaximum ? 'less than' : 'less than or equal to';
if (defined(items.minimum) && defined(items.maximum)) {
md += ' * Each element in the array must be ' + minString + ' ' + style.minMax(items.minimum) + ' and ' + maxString + ' ' + style.minMax(items.maximum) + '.\n';
} else if (defined(items.minimum)) {
md += ' * Each element in the array must be ' + minString + ' ' + style.minMax(items.minimum) + '.\n';
} else if (defined(items.maximum)) {
md += ' * Each element in the array must be ' + maxString + ' ' + style.minMax(items.maximum) + '.\n';
}
if (defined(items.minLength) && defined(items.maxLength)) {
md += ' * Each element in the array must have length between ' + style.minMax(items.minLength) + ' and ' + style.minMax(items.maxLength) + '.\n';
} else if (defined(items.minLength)) {
md += ' * Each element in the array must have length greater than or equal to ' + style.minMax(items.minLength) + '.\n';
} else if (defined(items.maxLength)) {
md += ' * Each element in the array must have length less than or equal to ' + style.minMax(items.maxLength) + '.\n';
}
var itemsString = getEnumString(items, type, 3);
if (defined(itemsString)) {
md += ' * Each element in the array must be one of the following values:\n' + itemsString;
}
}
md += '* ' + style.propertyDetails('Required') + ': ' + summary.required + '\n';
var minimum = property.minimum;
if (defined(minimum)) {
var exclusiveMinimum = (defined(property.exclusiveMinimum) && property.exclusiveMinimum);
md += '* ' + style.propertyDetails('Minimum') + ': ' + style.minMax((exclusiveMinimum ? ' > ' : ' >= ') + minimum) + '\n';
}
var maximum = property.maximum;
if (defined(maximum)) {
var exclusiveMaximum = (defined(property.exclusiveMaximum) && property.exclusiveMaximum);
md += '* ' + style.propertyDetails('Maximum') + ': ' + style.minMax((exclusiveMaximum ? ' < ' : ' <= ') + maximum) + '\n';
}
var format = property.format;
if (defined(format)) {
md += '* ' + style.propertyDetails('Format') + ': ' + format + '\n';
}
// TODO: maxLength
var minLength = property.minLength;
if (defined(minLength)) {
md += '* ' + style.propertyDetails('Minimum Length') + style.minMax(': >= ' + minLength) + '\n';
}
var enumString = getEnumString(property, type, 1);
if (defined(enumString)) {
md += '* ' + style.propertyDetails('Allowed values') + ':\n' + enumString;
}
var additionalProperties = property.additionalProperties;
if (defined(additionalProperties) && (typeof additionalProperties === 'object')) {
var additionalPropertiesType = getPropertyType(additionalProperties);
if (defined(additionalPropertiesType)) {
// TODO: additionalProperties is really a full schema
var formattedType = style.typeValue(additionalPropertiesType)
if ((additionalProperties.type === 'object') && defined(property.title)) {
formattedType = style.linkType(property.title, property.title, autoLink);
}
md += '* ' + style.propertyDetails('Type of each property') + ': ' + formattedType + '\n';
}
}
// TODO: fix adding samples later
// property.examples.forEach(function (example, i) {
// if (i == 0) {
// md += "\n" + style.getHeaderMarkdown("Example", 3);
// }
// md += getExampleForProperty(example);
// });
return md + '\n';
}