Skip to content

Hy, sorry for the delay, #21

@Mortiemi

Description

@Mortiemi
          Hy, sorry for the delay,

I've made theses modifications in your code to generate "patternProperties" like "properties" :

if (schemaType === 'object') {
        if (schema.properties) {
            text.push('Properties of the `' + name + '` object:')
            generatePropertySection(octothorpes, schema, subSchemas).forEach(function(section) {
                text = text.concat(section)
            })
        }
        if (schema.patternProperties) {
            text.push('Pattern properties of the `' + name + '` object pattern regexp:')
            generatePropertySection(octothorpes, schema, subSchemas).forEach(function(section) {
                text = text.concat(section)
            })
        }
    } else if (schemaType === 'array') {

And

function generatePropertySection(octothorpes, schema, subSchemas) {
    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)
        })
    } else if (schema.patternProperties) {
        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.oneOf) {
        var oneOfList = schema.oneOf.map(function(innerSchema) {

            return '* `' + getActualType(innerSchema, subSchemas) + '`'
        }).join('\n')
        return ['This property must be one of the following types:', oneOfList]
    } else {
        return []
    }
}

It's work very well in my case.

Guillaume

Originally posted by @niji-gmarion in #9 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions