outmoded / lout

API documentation generator
Other
276 stars 49 forks source link

Lout is failing on this particular nested Joi obj. #64

Closed brock8503 closed 10 years ago

brock8503 commented 10 years ago

Here is a particular testcase where lout is failing on a rule object that is not an Array.

validate: { 
    payload: { 
        param1: Joi.array().includes( Joi.object( { 
            param2: Joi.array().includes( Joi.object( { 
                param3 : Joi.string() } ) ).optional() 
            } ) 
         ) }
    } 
}

Simple fix would be to add protection, but I don't think that is the ideal solution.

@ln 193 index.js
} else if (data.type === 'array' && param.rules) {

        data.rules = {};

        param.rules.forEach(function (rule) {

            var capitalizedName = rule.name.charAt(0).toUpperCase() + rule.name.slice(1);

            if (Array.isArray(params.rule)) {
                data.rules[capitalizedName] = !Array.isArray(rule.arg) ? rule.arg : rule.arg.map(function (type) {

                    return internals.getParamsData(internals.describe(type));
                });
            }
        });
Marsup commented 10 years ago

And you're right, I did an awful mistake in 3.1.1. Publishing a fix in the next few minutes.

Marsup commented 10 years ago

OK the fix is now live on npm, sorry for letting this one slip.