diff --git a/lib/markdownBuilder.js b/lib/markdownBuilder.js index 49c8dd29..ce7c24e1 100644 --- a/lib/markdownBuilder.js +++ b/lib/markdownBuilder.js @@ -282,7 +282,7 @@ function build({ } function type(property) { - if (typeof property[keyword`type`] === 'object') { + if (!Array.isArray(property[keyword`type`]) && typeof property[keyword`type`] === 'object') { return text(i18n`Unknown Type`); } const types = Array.isArray(property[keyword`type`]) ? property[keyword`type`] : [property[keyword`type`]]; diff --git a/test/fixtures/nullable/array.schema.json b/test/fixtures/nullable/array.schema.json new file mode 100644 index 00000000..83b62e76 --- /dev/null +++ b/test/fixtures/nullable/array.schema.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "$id": "http://example.com/type-array-repro.json", + "type": "object", + "title": "Type Array Repro", + "description": "Type Array Issue Reproduction", + "required": [ + "sampleProp" + ], + "additionalProperties": false, + "properties": { + "sampleProp": { + "type": ["string", "null"], + "title": "Sample Property" + } + } +} \ No newline at end of file diff --git a/test/markdownBuilder.test.js b/test/markdownBuilder.test.js index 06327ed2..1a6cac83 100644 --- a/test/markdownBuilder.test.js +++ b/test/markdownBuilder.test.js @@ -62,6 +62,21 @@ not }); }); +describe('Testing Markdown Builder: nullable', () => { + let results; + + before(async () => { + const schemas = await loadschemas('nullable'); + const builder = build({ header: false }); + results = builder(schemas); + }); + + it('Nullable Array Type Schema looks OK', () => { + assertMarkdown(results.array) + .fuzzy`| [sampleProp](#sampleProp) | \`string\` | Required | can be null |`; + }); +}); + describe('Testing Markdown Builder: title', () => { let results;