From 8c76844c5dd6cfcb0389664f658f80d019c81f08 Mon Sep 17 00:00:00 2001 From: Lars Trieloff <trieloff@adobe.com> Date: Thu, 12 Apr 2018 14:54:02 +0000 Subject: [PATCH] Fix tests for attribute links --- cli.js | 1 - examples/abstract.md | 3 ++ examples/docs/abstract.schema.md | 4 +-- examples/docs/arrays.schema.md | 4 +-- examples/docs/complex.schema.md | 4 +-- examples/docs/constants.schema.md | 4 +-- examples/docs/custom.schema.md | 4 +-- examples/docs/deepextending.schema.md | 4 +-- examples/docs/definitions.schema.md | 4 +-- examples/docs/enums.schema.md | 4 +-- examples/docs/example.schema.md | 4 +-- examples/docs/examples.schema.md | 4 +-- examples/docs/extending.schema.md | 4 +-- examples/docs/extensible.schema.md | 4 +-- examples/docs/simple.schema.md | 4 +-- examples/docs/simpletypes.schema.md | 4 +-- examples/docs/stabilizing.schema.md | 4 +-- examples/docs/subdir/subdir.schema.md | 4 +-- examples/status.md | 3 ++ lib/header.js | 36 ++++++++++++++--------- lib/markdownWriter.js | 2 +- spec/examples/README.md | 27 +++++++++++++++++ spec/examples/abstract.schema.md | 4 +-- spec/examples/arrays.schema.md | 4 +-- spec/examples/complex.schema.md | 4 +-- spec/examples/constants.schema.md | 4 +-- spec/examples/custom.schema.md | 4 +-- spec/examples/deepextending.schema.md | 4 +-- spec/examples/definitions.schema.md | 4 +-- spec/examples/enums.schema.md | 4 +-- spec/examples/example.schema.md | 4 +-- spec/examples/examples.schema.md | 4 +-- spec/examples/extending.schema.md | 4 +-- spec/examples/extensible.schema.md | 4 +-- spec/examples/simple.schema.md | 4 +-- spec/examples/simpletypes.schema.md | 4 +-- spec/examples/stabilizing.schema.md | 4 +-- spec/examples/subdir/subdir.schema.md | 42 +++++++++++++++++++++++++++ spec/lib/integrationTest.spec.js | 38 +++++++++++++----------- 39 files changed, 182 insertions(+), 94 deletions(-) create mode 100644 examples/abstract.md create mode 100644 examples/status.md create mode 100644 spec/examples/README.md create mode 100644 spec/examples/subdir/subdir.schema.md diff --git a/cli.js b/cli.js index c63c923..8bd5c03 100644 --- a/cli.js +++ b/cli.js @@ -47,7 +47,6 @@ var argv = require('optimist') .argv; const docs = _.fromPairs(_.toPairs(argv).filter(([ key, value ]) => { return key.startsWith('link-'); }).map(([ key, value ]) => { return [ key.substr(5), value ];})); -console.log(docs); var ajv = new Ajv({ allErrors: true, messages:true }); ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json')); diff --git a/examples/abstract.md b/examples/abstract.md new file mode 100644 index 0000000..b941117 --- /dev/null +++ b/examples/abstract.md @@ -0,0 +1,3 @@ +# What is Abstract? + +Something that cannot be instantiated. diff --git a/examples/docs/abstract.schema.md b/examples/docs/abstract.schema.md index 6bd5774..a4e4b7e 100644 --- a/examples/docs/abstract.schema.md +++ b/examples/docs/abstract.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/abstract This is an abstract schema. It has `definitions`, but does not declare any properties -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Cannot be instantiated | Yes | Experimental | Forbidden | Permitted | [abstract.schema.json](abstract.schema.json) | # Abstract Definitions diff --git a/examples/docs/arrays.schema.md b/examples/docs/arrays.schema.md index ba969db..7b224d4 100644 --- a/examples/docs/arrays.schema.md +++ b/examples/docs/arrays.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/arrays This is an example schema with examples for multiple array types and their constraints. -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | No | Experimental | Forbidden | Permitted | [arrays.schema.json](arrays.schema.json) | # Arrays Properties diff --git a/examples/docs/complex.schema.md b/examples/docs/complex.schema.md index a58004d..44679c2 100644 --- a/examples/docs/complex.schema.md +++ b/examples/docs/complex.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/complex This is an example schema that uses types defined in other schemas. -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | No | Experimental | Forbidden | Permitted | [complex.schema.json](complex.schema.json) | ## Schema Hierarchy diff --git a/examples/docs/constants.schema.md b/examples/docs/constants.schema.md index f66f875..4dce795 100644 --- a/examples/docs/constants.schema.md +++ b/examples/docs/constants.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/constants This is an example schema with examples for properties with constant values -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | No | Experimental | Forbidden | Permitted | [constants.schema.json](constants.schema.json) | # Constant Types Properties diff --git a/examples/docs/custom.schema.md b/examples/docs/custom.schema.md index 885865a..fae3a98 100644 --- a/examples/docs/custom.schema.md +++ b/examples/docs/custom.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/custom This is an extensible schema. It has `definitions`, that can be used in other schemas. Additionally, it allows custom properties. -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | Yes | Experimental | Allowed | Permitted | [custom.schema.json](custom.schema.json) | # Custom Properties diff --git a/examples/docs/deepextending.schema.md b/examples/docs/deepextending.schema.md index ccb5ed6..9b124da 100644 --- a/examples/docs/deepextending.schema.md +++ b/examples/docs/deepextending.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/deepextending This is an extending schema. It is extending another extending schema. It pulls `definitions` from other schemas. -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | Yes | Experimental | Forbidden | Permitted | [deepextending.schema.json](deepextending.schema.json) | ## Schema Hierarchy diff --git a/examples/docs/definitions.schema.md b/examples/docs/definitions.schema.md index ebce6f9..fbd3031 100644 --- a/examples/docs/definitions.schema.md +++ b/examples/docs/definitions.schema.md @@ -25,8 +25,8 @@ Bre- aks. -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | Yes | Experimental | Forbidden | Permitted | [definitions.schema.json](definitions.schema.json) | # Definitions Properties diff --git a/examples/docs/enums.schema.md b/examples/docs/enums.schema.md index ef161c1..61b3a56 100644 --- a/examples/docs/enums.schema.md +++ b/examples/docs/enums.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/enums This is an example schema with examples for properties with enum values -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | No | Experimental | Forbidden | Permitted | [enums.schema.json](enums.schema.json) | # Enumerated Properties diff --git a/examples/docs/example.schema.md b/examples/docs/example.schema.md index 264bbaf..a606dbc 100644 --- a/examples/docs/example.schema.md +++ b/examples/docs/example.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/example This is an example schema with examples. Too many examples? There can never be too many examples! -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | No | Experimental | Forbidden | Permitted | [example.schema.json](example.schema.json) | ## Example Example diff --git a/examples/docs/examples.schema.md b/examples/docs/examples.schema.md index ad2db8a..cddde01 100644 --- a/examples/docs/examples.schema.md +++ b/examples/docs/examples.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/examples This is an example schema with *multiple* examples. Too many examples? There can never be too many examples! -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | No | Experimental | Forbidden | Permitted | [examples.schema.json](examples.schema.json) | ## Examples Examples diff --git a/examples/docs/extending.schema.md b/examples/docs/extending.schema.md index e952bee..e6b6b5f 100644 --- a/examples/docs/extending.schema.md +++ b/examples/docs/extending.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/extending This is an extending schema. It pulls `definitions` from other schemas. -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | Yes | Experimental | Forbidden | Permitted | [extending.schema.json](extending.schema.json) | ## Schema Hierarchy diff --git a/examples/docs/extensible.schema.md b/examples/docs/extensible.schema.md index a237e68..4582a93 100644 --- a/examples/docs/extensible.schema.md +++ b/examples/docs/extensible.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/extensible This is an extensible schema. It has `definitions`, that can be used in other schemas -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Cannot be instantiated | Yes | Experimental | Forbidden | Permitted | [extensible.schema.json](extensible.schema.json) | # Extensible Definitions diff --git a/examples/docs/simple.schema.md b/examples/docs/simple.schema.md index 5e5fa3d..6327fbf 100644 --- a/examples/docs/simple.schema.md +++ b/examples/docs/simple.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/simple This is a *very* simple example of a JSON schema. There is only one property. -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | No | Experimental | Forbidden | Permitted | [simple.schema.json](simple.schema.json) | # Simple Properties diff --git a/examples/docs/simpletypes.schema.md b/examples/docs/simpletypes.schema.md index 945c245..549ce86 100644 --- a/examples/docs/simpletypes.schema.md +++ b/examples/docs/simpletypes.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/simpletypes This is an example schema with examples for multiple types and their constraints. -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | No | Experimental | Forbidden | Permitted | [simpletypes.schema.json](simpletypes.schema.json) | # Simple Types Properties diff --git a/examples/docs/stabilizing.schema.md b/examples/docs/stabilizing.schema.md index b88ea2c..56c022f 100644 --- a/examples/docs/stabilizing.schema.md +++ b/examples/docs/stabilizing.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/stabilizing This is a schema which is currently in the `stabilizing` status. -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | No | Stabilizing | Forbidden | Permitted | [stabilizing.schema.json](stabilizing.schema.json) | # Stabilizing Properties diff --git a/examples/docs/subdir/subdir.schema.md b/examples/docs/subdir/subdir.schema.md index 673847a..54bd0ab 100644 --- a/examples/docs/subdir/subdir.schema.md +++ b/examples/docs/subdir/subdir.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/subdir/subdir A schema in a sub directory -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../../abstract.md) | Extensible | [Status](../../status.md) | Custom Properties | Additional Properties | Defined In | +|-------------------------------|------------|---------------------------|-------------------|-----------------------|------------| | Cannot be instantiated | Yes | Experimental | Forbidden | Permitted | [subdir/subdir.schema.json](subdir/subdir.schema.json) | # Subdir Definitions diff --git a/examples/status.md b/examples/status.md new file mode 100644 index 0000000..bb6aeb3 --- /dev/null +++ b/examples/status.md @@ -0,0 +1,3 @@ +# Status + +We know multiple stati diff --git a/lib/header.js b/lib/header.js index 5c7cd41..e20c200 100644 --- a/lib/header.js +++ b/lib/header.js @@ -5,7 +5,8 @@ * of the License at http://www.apache.org/licenses/LICENSE-2.0 */ -var _ = require('lodash'); +const _ = require('lodash'); +const path = require('path'); function custom(schema) { if (schema.allOf) { @@ -30,20 +31,21 @@ function schemaProps(schema, schemaPath, filename) { } class Header { - constructor(name, docs, value, links) { + constructor(name, docs, value, links, base) { this.name = name; this.docs = docs; this.value = value; this.links = links; + this.base = base || ''; - this.renderHeader = this.render(this.name, this.docs); - this.renderValue = this.render(this.value, this.links); + this.renderHeader = this.render(this.name, this.docs, this.base); + this.renderValue = this.render(this.value, this.links, this.base); } - render(text, link) { + render(text, link, base) { return function() { if (link) { - return `[${text}](${link})`; + return `[${text}](${base}${link})`; } else { return text; } @@ -73,16 +75,24 @@ function header(name, docs, value, links) { return this; } -function headers(schema, path, filename, docs) { - const props = schemaProps(schema, path, filename); +function link(indir, filename, inlink) { + if (inlink) { + return path.relative(path.relative(indir, filename), inlink); + } else { + return inlink; + } +} + +function headers(schema, indir, filename, docs, outdir) { + const props = schemaProps(schema, indir, filename); this.doclinks = docs ? docs : {}; this.myheaders = []; - this.myheaders.push(new Header('Abstract', this.doclinks['abstract'], props.abstract)); - this.myheaders.push(new Header('Extensible', this.doclinks['extensible'], props.extensible)); - this.myheaders.push(new Header('Status', this.doclinks['status'], props.status)); - this.myheaders.push(new Header('Custom Properties', this.doclinks['custom'], props.custom)); - this.myheaders.push(new Header('Additional Properties', this.doclinks['additional'], schema.additionalProperties===false ? 'Forbidden' : 'Permitted')); + this.myheaders.push(new Header('Abstract', link(indir, filename, this.doclinks['abstract']), props.abstract)); + this.myheaders.push(new Header('Extensible', link(indir, filename, this.doclinks['extensible']), props.extensible)); + this.myheaders.push(new Header('Status', link(indir, filename, this.doclinks['status']), props.status)); + this.myheaders.push(new Header('Custom Properties', link(indir, filename, this.doclinks['custom']), props.custom)); + this.myheaders.push(new Header('Additional Properties', link(indir, filename, this.doclinks['additional']), schema.additionalProperties===false ? 'Forbidden' : 'Permitted')); this.myheaders.push(new Header('Defined In', undefined, props.original, props.original)); this.render = function() { diff --git a/lib/markdownWriter.js b/lib/markdownWriter.js index 31320e9..7bd275b 100644 --- a/lib/markdownWriter.js +++ b/lib/markdownWriter.js @@ -151,7 +151,7 @@ const generateMarkdown = function(filename, schema, schemaPath, outDir, dependen [ 'header.ejs', { schema: schema, dependencies: flatten(dependencyMap), - table: headers(schema, schemaPath, filename, docs).render() } ], + table: headers(schema, schemaPath, filename, docs, outDir).render() } ], //[ 'divider.ejs', null ], //[ 'topSchema.ejs', ctx ], [ 'examples.ejs', { examples: stringifyExamples(schema.examples), title: schema.title } ] diff --git a/spec/examples/README.md b/spec/examples/README.md new file mode 100644 index 0000000..896a8a1 --- /dev/null +++ b/spec/examples/README.md @@ -0,0 +1,27 @@ + + + # Readme + + + +## / + +* [Abstract](./abstract.schema.md) – `https://example.com/schemas/abstract` +* [Arrays](./arrays.schema.md) – `https://example.com/schemas/arrays` +* [Complex References ](./complex.schema.md) – `https://example.com/schemas/complex` +* [Constant Types](./constants.schema.md) – `https://example.com/schemas/constants` +* [Custom](./custom.schema.md) – `https://example.com/schemas/custom` +* [Deeply Extending](./deepextending.schema.md) – `https://example.com/schemas/deepextending` +* [Definitions](./definitions.schema.md) – `https://example.com/schemas/definitions` +* [Enumerated ](./enums.schema.md) – `https://example.com/schemas/enums` +* [Example](./example.schema.md) – `https://example.com/schemas/example` +* [Examples](./examples.schema.md) – `https://example.com/schemas/examples` +* [Extending](./extending.schema.md) – `https://example.com/schemas/extending` +* [Extensible](./extensible.schema.md) – `https://example.com/schemas/extensible` +* [Simple](./simple.schema.md) – `https://example.com/schemas/simple` +* [Simple Types](./simpletypes.schema.md) – `https://example.com/schemas/simpletypes` +* [Stabilizing](./stabilizing.schema.md) – `https://example.com/schemas/stabilizing` + +## /subdir/ + +* [Subdir](./subdir/subdir.schema.md) – `https://example.com/schemas/subdir/subdir` diff --git a/spec/examples/abstract.schema.md b/spec/examples/abstract.schema.md index 6bd5774..a4e4b7e 100644 --- a/spec/examples/abstract.schema.md +++ b/spec/examples/abstract.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/abstract This is an abstract schema. It has `definitions`, but does not declare any properties -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Cannot be instantiated | Yes | Experimental | Forbidden | Permitted | [abstract.schema.json](abstract.schema.json) | # Abstract Definitions diff --git a/spec/examples/arrays.schema.md b/spec/examples/arrays.schema.md index ba969db..7b224d4 100644 --- a/spec/examples/arrays.schema.md +++ b/spec/examples/arrays.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/arrays This is an example schema with examples for multiple array types and their constraints. -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | No | Experimental | Forbidden | Permitted | [arrays.schema.json](arrays.schema.json) | # Arrays Properties diff --git a/spec/examples/complex.schema.md b/spec/examples/complex.schema.md index a58004d..44679c2 100644 --- a/spec/examples/complex.schema.md +++ b/spec/examples/complex.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/complex This is an example schema that uses types defined in other schemas. -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | No | Experimental | Forbidden | Permitted | [complex.schema.json](complex.schema.json) | ## Schema Hierarchy diff --git a/spec/examples/constants.schema.md b/spec/examples/constants.schema.md index f66f875..4dce795 100644 --- a/spec/examples/constants.schema.md +++ b/spec/examples/constants.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/constants This is an example schema with examples for properties with constant values -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | No | Experimental | Forbidden | Permitted | [constants.schema.json](constants.schema.json) | # Constant Types Properties diff --git a/spec/examples/custom.schema.md b/spec/examples/custom.schema.md index 885865a..fae3a98 100644 --- a/spec/examples/custom.schema.md +++ b/spec/examples/custom.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/custom This is an extensible schema. It has `definitions`, that can be used in other schemas. Additionally, it allows custom properties. -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | Yes | Experimental | Allowed | Permitted | [custom.schema.json](custom.schema.json) | # Custom Properties diff --git a/spec/examples/deepextending.schema.md b/spec/examples/deepextending.schema.md index ccb5ed6..9b124da 100644 --- a/spec/examples/deepextending.schema.md +++ b/spec/examples/deepextending.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/deepextending This is an extending schema. It is extending another extending schema. It pulls `definitions` from other schemas. -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | Yes | Experimental | Forbidden | Permitted | [deepextending.schema.json](deepextending.schema.json) | ## Schema Hierarchy diff --git a/spec/examples/definitions.schema.md b/spec/examples/definitions.schema.md index ebce6f9..fbd3031 100644 --- a/spec/examples/definitions.schema.md +++ b/spec/examples/definitions.schema.md @@ -25,8 +25,8 @@ Bre- aks. -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | Yes | Experimental | Forbidden | Permitted | [definitions.schema.json](definitions.schema.json) | # Definitions Properties diff --git a/spec/examples/enums.schema.md b/spec/examples/enums.schema.md index ef161c1..61b3a56 100644 --- a/spec/examples/enums.schema.md +++ b/spec/examples/enums.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/enums This is an example schema with examples for properties with enum values -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | No | Experimental | Forbidden | Permitted | [enums.schema.json](enums.schema.json) | # Enumerated Properties diff --git a/spec/examples/example.schema.md b/spec/examples/example.schema.md index 264bbaf..a606dbc 100644 --- a/spec/examples/example.schema.md +++ b/spec/examples/example.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/example This is an example schema with examples. Too many examples? There can never be too many examples! -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | No | Experimental | Forbidden | Permitted | [example.schema.json](example.schema.json) | ## Example Example diff --git a/spec/examples/examples.schema.md b/spec/examples/examples.schema.md index ad2db8a..cddde01 100644 --- a/spec/examples/examples.schema.md +++ b/spec/examples/examples.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/examples This is an example schema with *multiple* examples. Too many examples? There can never be too many examples! -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | No | Experimental | Forbidden | Permitted | [examples.schema.json](examples.schema.json) | ## Examples Examples diff --git a/spec/examples/extending.schema.md b/spec/examples/extending.schema.md index e952bee..e6b6b5f 100644 --- a/spec/examples/extending.schema.md +++ b/spec/examples/extending.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/extending This is an extending schema. It pulls `definitions` from other schemas. -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | Yes | Experimental | Forbidden | Permitted | [extending.schema.json](extending.schema.json) | ## Schema Hierarchy diff --git a/spec/examples/extensible.schema.md b/spec/examples/extensible.schema.md index a237e68..4582a93 100644 --- a/spec/examples/extensible.schema.md +++ b/spec/examples/extensible.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/extensible This is an extensible schema. It has `definitions`, that can be used in other schemas -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Cannot be instantiated | Yes | Experimental | Forbidden | Permitted | [extensible.schema.json](extensible.schema.json) | # Extensible Definitions diff --git a/spec/examples/simple.schema.md b/spec/examples/simple.schema.md index 5e5fa3d..6327fbf 100644 --- a/spec/examples/simple.schema.md +++ b/spec/examples/simple.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/simple This is a *very* simple example of a JSON schema. There is only one property. -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | No | Experimental | Forbidden | Permitted | [simple.schema.json](simple.schema.json) | # Simple Properties diff --git a/spec/examples/simpletypes.schema.md b/spec/examples/simpletypes.schema.md index 945c245..549ce86 100644 --- a/spec/examples/simpletypes.schema.md +++ b/spec/examples/simpletypes.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/simpletypes This is an example schema with examples for multiple types and their constraints. -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | No | Experimental | Forbidden | Permitted | [simpletypes.schema.json](simpletypes.schema.json) | # Simple Types Properties diff --git a/spec/examples/stabilizing.schema.md b/spec/examples/stabilizing.schema.md index b88ea2c..56c022f 100644 --- a/spec/examples/stabilizing.schema.md +++ b/spec/examples/stabilizing.schema.md @@ -11,8 +11,8 @@ https://example.com/schemas/stabilizing This is a schema which is currently in the `stabilizing` status. -| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In | -|----------|------------|--------|-------------------|-----------------------|------------| +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|-------------------|-----------------------|------------| | Can be instantiated | No | Stabilizing | Forbidden | Permitted | [stabilizing.schema.json](stabilizing.schema.json) | # Stabilizing Properties diff --git a/spec/examples/subdir/subdir.schema.md b/spec/examples/subdir/subdir.schema.md new file mode 100644 index 0000000..54bd0ab --- /dev/null +++ b/spec/examples/subdir/subdir.schema.md @@ -0,0 +1,42 @@ +--- +template: reference +foo: bar +--- + +# Subdir Schema + +``` +https://example.com/schemas/subdir/subdir +``` + +A schema in a sub directory + +| [Abstract](../../abstract.md) | Extensible | [Status](../../status.md) | Custom Properties | Additional Properties | Defined In | +|-------------------------------|------------|---------------------------|-------------------|-----------------------|------------| +| Cannot be instantiated | Yes | Experimental | Forbidden | Permitted | [subdir/subdir.schema.json](subdir/subdir.schema.json) | + +# Subdir Definitions + +| Property | Type | Group | +|----------|------|-------| +| [id](#id) | `string` | `https://example.com/schemas/subdir/subdir#/definitions/content` | + +## 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/spec/lib/integrationTest.spec.js b/spec/lib/integrationTest.spec.js index 05a612c..f663e46 100644 --- a/spec/lib/integrationTest.spec.js +++ b/spec/lib/integrationTest.spec.js @@ -1,14 +1,16 @@ const { spawn } = require('child_process'); -const { readFile, readdirSync } = require('fs'); +const { readFile, readdirSync, statSync } = require('fs'); beforeEach(function() { - jasmine.addMatchers(require('jasmine-diff')(jasmine, { - colors: true, - inline: true - })); + jasmine.addMatchers( + require('jasmine-diff')(jasmine, { + colors: true, + inline: true + }) + ); }); -describe('Process examples', () => { +describe('Compare results', () => { it('Run jsonschema2md on example schemas', done => { const ls = spawn('node', [ 'cli.js', @@ -23,7 +25,9 @@ describe('Process examples', () => { '-m', 'foo=bar', '--link-abstract', - '../abstract.md' + 'abstract.md', + '--link-status', + 'status.md' ]); ls.on('close', code => { @@ -31,22 +35,22 @@ describe('Process examples', () => { done(); }); }); -}); -describe('Compare results', () => { const files = readdirSync('./spec/examples'); files.forEach(file => { - it('Comparing ' + file, done => { - console.log('file ' + file); - readFile('./spec/examples/' + file, (err, expectedbuf) => { - expect(err).toBeNull(); - readFile('./examples/docs/' + file, (err, actualbuf) => { + if (statSync('./spec/examples/' + file).isFile()) { + it('Comparing ' + file, done => { + console.log('file ' + file); + readFile('./spec/examples/' + file, (err, expectedbuf) => { expect(err).toBeNull(); - expect(actualbuf.toString()).toEqual(expectedbuf.toString()); - done(); + readFile('./examples/docs/' + file, (err, actualbuf) => { + expect(err).toBeNull(); + expect(actualbuf.toString()).toEqual(expectedbuf.toString()); + done(); + }); }); }); - }); + } }); }); -- GitLab