Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hy, sorry for the delay, #21

Open
Mortiemi opened this issue Dec 1, 2024 · 0 comments
Open

Hy, sorry for the delay, #21

Mortiemi opened this issue Dec 1, 2024 · 0 comments

Comments

@Mortiemi
Copy link

Mortiemi commented Dec 1, 2024

          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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant