Skip to content
Snippets Groups Projects
Commit ed7cfd2d authored by Lars Trieloff's avatar Lars Trieloff
Browse files

Generate property details for definitions #14

parent 522889da
Branches
No related tags found
No related merge requests found
...@@ -21,3 +21,41 @@ This is an abstract schema. It has `definitions`, but does not declare any prope ...@@ -21,3 +21,41 @@ This is an abstract schema. It has `definitions`, but does not declare any prope
|----------|------| |----------|------|
| [foo](#foo) | `string` | | [foo](#foo) | `string` |
| [bar](#bar) | `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`
...@@ -21,3 +21,58 @@ This is an extensible schema. It has `definitions`, that can be used in other sc ...@@ -21,3 +21,58 @@ This is an extensible schema. It has `definitions`, that can be used in other sc
|----------|------| |----------|------|
| [foo](#foo) | `string` | | [foo](#foo) | `string` |
| [bar](#bar) | `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"
```
...@@ -20,3 +20,23 @@ A schema in a sub directory ...@@ -20,3 +20,23 @@ A schema in a sub directory
| Property | Type | | Property | Type |
|----------|------| |----------|------|
| [id](#id) | `string` | | [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))
...@@ -164,7 +164,7 @@ const generateMarkdown = function(filename, schema, schemaPath, outDir, dependen ...@@ -164,7 +164,7 @@ const generateMarkdown = function(filename, schema, schemaPath, outDir, dependen
schema: simpletype(schema.properties[_.keys(schema.properties)[i]]) } ]); 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) { if (_.keys(schema.definitions).length > 0) {
const abstract = {}; const abstract = {};
for (let i=0; i<_.keys(schema.definitions).length;i++) { for (let i=0; i<_.keys(schema.definitions).length;i++) {
...@@ -181,8 +181,15 @@ const generateMarkdown = function(filename, schema, schemaPath, outDir, dependen ...@@ -181,8 +181,15 @@ const generateMarkdown = function(filename, schema, schemaPath, outDir, dependen
} }
} }
if (_.keys(abstract).length>0) { 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 } ]); 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]]) } ]);
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment