diff --git a/lib/markdownBuilder.js b/lib/markdownBuilder.js index 83a7607f..305144b0 100644 --- a/lib/markdownBuilder.js +++ b/lib/markdownBuilder.js @@ -278,9 +278,9 @@ export default function build({ (prop) => { // this is a linked property if (schema[s.meta] - && typeof schema[s.meta][prop.name] === 'object' - && schema[s.meta][prop.name].link - && schema[s.meta][prop.name].text) { + && typeof schema[s.meta][prop.name] === 'object' + && schema[s.meta][prop.name].link + && schema[s.meta][prop.name].text) { return tableCell(link(rewritelinks(schema[s.meta][prop.name].link), i18n`open original schema`, [text(schema[s.meta][prop.name].text)])); } const value = schema[s.meta] ? schema[s.meta][prop.name] : undefined; @@ -398,11 +398,11 @@ export default function build({ return [listItem(paragraph(text(i18n`and all following items may follow any schema`)))]; } else if (typeof additional === 'object') { return [listItem(paragraph([text(i18n`and all following items must follow the schema: `), - link( - `${additional[s.slug]}.md`, - i18n`check type definition`, - text(gentitle(additional[s.titles], additional[keyword`type`])), - )]))]; + link( + `${additional[s.slug]}.md`, + i18n`check type definition`, + text(gentitle(additional[s.titles], additional[keyword`type`])), + )]))]; } return []; })(), @@ -579,10 +579,10 @@ export default function build({ tableCell(text(i18n`Value`)), tableCell(text(i18n`Explanation`)), ]), - ...schema[keyword`enum`].map((value) => tableRow([ + ...(Array.isArray(schema[keyword`enum`]) ? schema[keyword`enum`].map((value) => tableRow([ tableCell(inlineCode(JSON.stringify(value))), tableCell(text(metas[Array.isArray(value) ? JSON.stringify(value) : value] || '')), - ])), + ])) : []), ])); } @@ -664,12 +664,12 @@ export default function build({ if (schema[keyword`minContains`] !== undefined && schema[keyword`contains`]) { // console.log('minContains!', schema[s.filename], schema[s.pointer]); constraints.push(paragraph([strong(text(i18n`minimum number of contained items`)), text(': '), text(`${i18n`this array may not contain fewer than ${String(schema[keyword`minContains`])} items that validate against the schema:`} `), - link(`${schema[keyword`contains`][s.slug]}.md`, i18n`check type definition`, text(gentitle(schema[keyword`contains`][s.titles], schema[keyword`contains`][keyword`type`])))])); + link(`${schema[keyword`contains`][s.slug]}.md`, i18n`check type definition`, text(gentitle(schema[keyword`contains`][s.titles], schema[keyword`contains`][keyword`type`])))])); } if (schema[keyword`maxContains`] !== undefined && schema[keyword`contains`]) { // console.log('maxContains!', schema[s.filename], schema[s.pointer]); constraints.push(paragraph([strong(text(i18n`maximum number of contained items`)), text(': '), text(`${i18n`this array may not contain more than ${String(schema[keyword`maxContains`])} items that validate against the schema:`} `), - link(`${schema[keyword`contains`][s.slug]}.md`, i18n`check type definition`, text(gentitle(schema[keyword`contains`][s.titles], schema[keyword`contains`][keyword`type`])))])); + link(`${schema[keyword`contains`][s.slug]}.md`, i18n`check type definition`, text(gentitle(schema[keyword`contains`][s.titles], schema[keyword`contains`][keyword`type`])))])); } // https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.5