From ed7cfd2df9d6c638700f3ba834994cbc0847c343 Mon Sep 17 00:00:00 2001 From: Lars Trieloff <trieloff@adobe.com> Date: Thu, 14 Dec 2017 16:41:24 +0000 Subject: [PATCH] Generate property details for definitions #14 --- examples/docs/abstract.schema.md | 38 ++++++++++++++++++ examples/docs/extensible.schema.md | 55 +++++++++++++++++++++++++++ examples/docs/subdir/subdir.schema.md | 20 ++++++++++ lib/markdownWriter.js | 11 +++++- 4 files changed, 122 insertions(+), 2 deletions(-) diff --git a/examples/docs/abstract.schema.md b/examples/docs/abstract.schema.md index 43aff6d..d233ffd 100644 --- a/examples/docs/abstract.schema.md +++ b/examples/docs/abstract.schema.md @@ -21,3 +21,41 @@ This is an abstract schema. It has `definitions`, but does not declare any prope |----------|------| | [foo](#foo) | `string` | | [bar](#bar) | `string` | + +## foo + +A unique identifier given to every addressable thing. + +`foo` +* is optional +* type: `string` +* defined in this schema + +### foo Type + + +`string` + + + + + + +## bar + +A unique identifier given to every addressable thing. + +`bar` +* is optional +* type: `string` +* defined in this schema + +### bar Type + + +`string` + + + + + diff --git a/examples/docs/extensible.schema.md b/examples/docs/extensible.schema.md index d685f95..7c9a325 100644 --- a/examples/docs/extensible.schema.md +++ b/examples/docs/extensible.schema.md @@ -21,3 +21,58 @@ This is an extensible schema. It has `definitions`, that can be used in other sc |----------|------| | [foo](#foo) | `string` | | [bar](#bar) | `string` | + +## foo + +A unique identifier given to every addressable thing. + +`foo` +* is optional +* type: `string` +* defined in this schema + +### foo Type + + +`string` + + + + + +### foo Example + +```json +"bar" +``` + + +## bar + +A horse walks into it. + +`bar` +* is optional +* type: `string` +* defined in this schema + +### bar Type + + +`string` + + + + + +### bar Examples + +```json +"whoo" +``` + +```json +"hoo" +``` + + diff --git a/examples/docs/subdir/subdir.schema.md b/examples/docs/subdir/subdir.schema.md index c7dc9e8..4f00d1f 100644 --- a/examples/docs/subdir/subdir.schema.md +++ b/examples/docs/subdir/subdir.schema.md @@ -20,3 +20,23 @@ A schema in a sub directory | Property | Type | |----------|------| | [id](#id) | `string` | + +## id + +A unique identifier given to every addressable thing. + +`id` +* is optional +* type: `string` +* defined in this schema + +### id Type + + +`string` +* format: `uri` Uniformous Resource Identifier (according to [RFC3986](http://tools.ietf.org/html/rfc3986)) + + + + + diff --git a/lib/markdownWriter.js b/lib/markdownWriter.js index 31e217b..4b9529c 100644 --- a/lib/markdownWriter.js +++ b/lib/markdownWriter.js @@ -164,7 +164,7 @@ const generateMarkdown = function(filename, schema, schemaPath, outDir, dependen schema: simpletype(schema.properties[_.keys(schema.properties)[i]]) } ]); } } - + //find definitions that contain properties that are not part of the main schema if (_.keys(schema.definitions).length > 0) { const abstract = {}; for (let i=0; i<_.keys(schema.definitions).length;i++) { @@ -181,8 +181,15 @@ const generateMarkdown = function(filename, schema, schemaPath, outDir, dependen } } if (_.keys(abstract).length>0) { - console.log('I got definitions!', abstract); + //console.log('I got definitions!', abstract); multi.push([ 'definitions.ejs', { props: requiredProperties(abstract), title: schema.title } ]); + for (let i=0; i<_.keys(abstract).length;i++) { + multi.push( [ 'property.ejs', { + name: _.keys(abstract)[i], + required: false, + examples: stringifyExamples(abstract[_.keys(abstract)[i]]['examples']), + schema: simpletype(abstract[_.keys(abstract)[i]]) } ]); + } } } -- GitLab