diff --git a/lib/formatInfo.js b/lib/formatInfo.js index 1da148de..774683b9 100644 --- a/lib/formatInfo.js +++ b/lib/formatInfo.js @@ -85,15 +85,45 @@ function formatInfo({ extension }) { .length > 0; } + function getdefined(schema) { + if (schema.rootpath) { + return { + text: path.basename(schema.rootpath) + "*", + link: schema.rootpath + } + } + if (schema.path) { + return { + text: path.basename(schema.path), + link: schema.path + } + } + return undefined; + } + + function gettype(schema) { + if (typeof schema.type === 'string') { + return schema.type; + } + if (Array.isArray(schema.type)) { + return 'multiple'; + } + if (isabstract(schema)) { + return gettype(schema.definitions); + } + return undefined; + } + function formatmeta(schema) { return { + type: gettype(schema.schema), abstract: isabstract(schema.schema), extensible: isextensible(schema.schema), status: schema.schema['meta:status'] || undefined, identifiable: isidentifiable(schema.schema), custom: iscustom(schema.schema), - additional: undefined, - definedin: undefined + additional: schema.schema.additionalProperties !== false, + definedin: getdefined(schema) }; } diff --git a/lib/markdownBuilder.js b/lib/markdownBuilder.js index 5c989908..04411aca 100644 --- a/lib/markdownBuilder.js +++ b/lib/markdownBuilder.js @@ -18,6 +18,12 @@ const { function build({ header, links = {} }) { const headerprops = [ + { + name: 'type', + title: 'Type', + objectlabel: 'Object', + arraylabel: 'Array', + }, { name: 'abstract', title: 'Abstract', @@ -63,7 +69,7 @@ function build({ header, links = {} }) { undefinedlabel: 'Unknown additional properties' }, { - name: 'defined', + name: 'definedin', title: 'Defined In', undefinedlabel: 'Unknown definition' }, @@ -94,12 +100,11 @@ function build({ header, links = {} }) { map(headerprops, (prop) => { // this is a linked property - if (schema.meta && - schema.meta[prop.name] && - typeof schema.meta[prop.name] !== 'object' && - typeof schema.meta[prop.name].link === 'string') { - return tableCell(link(schema.meta[prop.name].link, '', text(schema.meta[prop.name].text))); + typeof schema.meta[prop.name] === 'object' && + schema.meta[prop.name].link && + schema.meta[prop.name].text) { + return tableCell(link(schema.meta[prop.name].link, 'open original schema', [text(schema.meta[prop.name].text)])); } const value = schema.meta ? schema.meta[prop.name] : undefined; return tableCell(text(prop[String(value) + 'label'] || 'Unknown')); diff --git a/lib/traverseSchema.js b/lib/traverseSchema.js index fc38ae85..0bc820b3 100644 --- a/lib/traverseSchema.js +++ b/lib/traverseSchema.js @@ -56,6 +56,7 @@ const ignoreKeywords = [ */ function traverse(node) { const { schema, pointer = '', id } = node; + const rootpath = node.rootpath ? node.rootpath : node.path; const items = pipe( // turn the schema object into a sequence of key value pairs iter(schema), @@ -71,6 +72,7 @@ function traverse(node) { pointer: `${pointer}/${key}/${index}`, id, root: schema, + rootpath, // TODO add additional properties for tracking })), ); @@ -85,6 +87,7 @@ function traverse(node) { pointer: `${pointer}/${key}/${subkey}`, id, root: schema, + rootpath, // TODO add additional properties for tracking })), ); @@ -97,6 +100,7 @@ function traverse(node) { pointer: `${pointer}/${key}`, id, root: schema, + rootpath, // TODO add additional properties for tracking }]; }