api-doc-validator
Advanced tools
Comparing version 2.16.0 to 2.17.0
@@ -51,4 +51,5 @@ module.exports = ajvToJsDoc; | ||
const props = schema.properties; | ||
const patterns = schema.patternProperties; | ||
if (!props) { | ||
if (!props && !patterns) { | ||
return anyObject; | ||
@@ -61,8 +62,17 @@ } | ||
'{' + | ||
Object.keys(props) | ||
Object.keys(props || {}) | ||
.map(function (prop) { | ||
const name = JSON.stringify(prop).replace(/^"([a-z_$][\w$]*)"$/i, '$1'); | ||
const name = normalizeProp(prop); | ||
return `${name}${req.includes(prop) ? '' : '?'}: ${ajvToJsDoc(props[prop], params)}`; | ||
}) | ||
.concat( | ||
Object.keys(patterns || {}) | ||
.map(function (regex, i, list) { | ||
const name = list.length > 1 ? 'prop' + (i + 1) : 'prop'; | ||
const type = regex === '^\\d+$' || regex === '^\\d$' ? 'number' : 'string'; | ||
return `[${name}: ${type}]: ${ajvToJsDoc(patterns[regex], params)}`; | ||
}) | ||
) | ||
.join(', ') | ||
@@ -116,2 +126,6 @@ + '}' | ||
return name.replace(/\./g, '__'); | ||
} | ||
function normalizeProp(prop) { | ||
return JSON.stringify(prop).replace(/^"([a-z_$][\w$]*)"$/i, '$1'); | ||
} |
{ | ||
"name": "api-doc-validator", | ||
"version": "2.16.0", | ||
"version": "2.17.0", | ||
"description": "api doc and validator", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63867
1802