apidoc-light
Advanced tools
Comparing version 0.51.0 to 0.51.1
@@ -512,11 +512,20 @@ /* | ||
for (const block of parsedBlocks) { | ||
let paramFields = block.local.parameter && block.local.parameter.fields && block.local.parameter.fields.Parameter; | ||
if (!paramFields) { | ||
paramFields = []; | ||
let paramFields = []; | ||
if (block.local.parameter && block.local.parameter.fields) { | ||
// Loop all fields regardless of the field group. The default field group is `Parameter` but it could be provided by the developer. | ||
for (const key in block.local.parameter.fields) { | ||
paramFields = paramFields.concat(block.local.parameter.fields[key]); | ||
} | ||
} | ||
const urlParams = []; | ||
if (block.local.url) { | ||
for (const urlFrag of block.local.url.split('/')) { | ||
if (urlFrag[0] === ':') { | ||
urlParams.push(urlFrag.slice(1)); | ||
// The dummy URL base is only used for parses of relative URLs. | ||
const url = new URL(block.local.url, 'https://dummy.base'); | ||
// For API parameters in the URL parts delimited by `/` (e.g. `/:foo/:bar`). | ||
for (const pathnamePart of url.pathname.split('/')) { | ||
if (pathnamePart.charAt(0) === ':') { | ||
urlParams.push(pathnamePart.slice(1)); | ||
} | ||
@@ -531,3 +540,4 @@ } | ||
for (const paramField of paramFields) { | ||
if (!urlParams.some(up => up === paramField.field)) { | ||
// Emit the warning only if the field is mandatory. | ||
if (!paramField.optional && !urlParams.some(up => up === paramField.field)) { | ||
log.warn(`@apiParam '${paramField.field}' was defined but does not appear in URL of @api '${block.local.title}' in file: '${filename}'`); | ||
@@ -534,0 +544,0 @@ } |
{ | ||
"name": "apidoc-light", | ||
"version": "0.51.0", | ||
"version": "0.51.1", | ||
"description": "RESTful web API Documentation Generator", | ||
@@ -5,0 +5,0 @@ "author": { |
220620
3498