Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ function generateSchemaSectionText(octothorpes, name, isRequired, schema, subSch
text = text.concat(section)
})
}
if (schema.patternProperties) {
text.push('Pattern properties of the `' + name + '` object pattern regexp:')
generatePropertySection(octothorpes, schema, subSchemas, true).forEach(function(section) {
text = text.concat(section)
})
}
} else if (schemaType === 'array') {
var itemsType = schema.items && schema.items.type

Expand Down Expand Up @@ -144,8 +150,14 @@ function generateSchemaSectionText(octothorpes, name, isRequired, schema, subSch
return text
}

function generatePropertySection(octothorpes, schema, subSchemas) {
if (schema.properties) {
function generatePropertySection(octothorpes, schema, subSchemas, isPatternProperties) {
if (isPatternProperties) {
return Object.keys(schema.patternProperties).map(function(patternPropertyKey) {
var patternPropertyIsRequired = schema.required && schema.required.indexOf(patternPropertyKey) >= 0
return generateSchemaSectionText(octothorpes + '#', patternPropertyKey, patternPropertyIsRequired, schema.patternProperties[patternPropertyKey], subSchemas)
})
}
else if (schema.properties) {
return Object.keys(schema.properties).map(function(propertyKey) {
var propertyIsRequired = schema.required && schema.required.indexOf(propertyKey) >= 0
return generateSchemaSectionText(octothorpes + '#', propertyKey, propertyIsRequired, schema.properties[propertyKey], subSchemas)
Expand Down