diff --git a/cli.js b/cli.js index c63c923a75eb82a9a139d19b2dfa16043d4e9120..8bd5c0346c6d75a411680f33809c356e5f8d59a6 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 0000000000000000000000000000000000000000..b941117f58877af9a4c5f710cb04ea1d9960b93e --- /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 6bd57741d39e62d9f16b4d3f408acd0c3dc0f331..a4e4b7e958808b7aed0ecd8cd5c9ae6d1ec81f03 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 ba969dbab53e8dc9f13d67a30d84c45d5e31d657..7b224d4050f08d79b81ded276471a3b97e4a5686 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 a58004d6b03d5ff229448f0244f20e238e3aa775..44679c259cae5eb500dfbe0e8347eb55c0d72eb1 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 f66f875bbfa6c9925ebaf656d0296a52e7458377..4dce7954acee92a1bf37b2f1a260965f9216124e 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 885865af5c4d0ac201b5df3c53bfcacd76921947..fae3a9843b02175774c771ba4f06bff760df4d31 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 ccb5ed6ec6a3aa620fdf5b97c87a044e66125513..9b124da0c73ac81241152c9c42b5974340d34425 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 ebce6f9c29d3cae85a64fc43b5f93443d9ede13e..fbd3031c9d1f091e85e1be3f06f914669974a710 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 ef161c163929e32a4d5794a93ba1ab3cad80568a..61b3a56af4cb4a4434a6c0fc4b7f04ae53eda950 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 264bbaf90835f11fbf6ad518b6f89211aad6af7f..a606dbc82a6d592e699d0007a7419bd26929483e 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 ad2db8a2a7ed95961344bb7ac61ca430a47a24c1..cddde01fb8262dce9db404e35e8b29fca38c50f6 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 e952bee82f5bc471e169ec46277343590a420773..e6b6b5f09f3784312987179f04f4d679e8afcdf7 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 a237e6889283e6fdf30e2adb11ce1e8c56877720..4582a9382096859523bc42c15d9f9ceaed3d8c79 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 5e5fa3d48dfcfda9c4d5be5f7abf2a4e88337fc4..6327fbf44d2034afb9f044c366aff30521de3608 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 945c245e97f7b61f10850bd9357975406d25b6ac..549ce86d2561baa0318fcce74b51ec9295c938ef 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 b88ea2c5e3fffc934aec534cbbbb7ba005862dc2..56c022f8e09c011387c2cde6aaf891ad199bb153 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 673847a9c5b761ff061ca8f9bd95abc06a1a1052..54bd0ab9e08e80cc6bb822204a1eae29c6d59d60 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 0000000000000000000000000000000000000000..bb6aeb353045d1159f8eb9dc438eb5d75a94f7d5 --- /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 5c7cd4109f623d4e50836a49e9d68456788156df..e20c200baf7db1f466dc26e6033c450f6d2fd6ba 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 31320e9a3f3a17ff4834a461193d0a2e641ce5ac..7bd275b6a0c7904e9e5980772a16e31b1b1feb8e 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 0000000000000000000000000000000000000000..896a8a1f46598d8b780d61430d8847fb6139a7fb --- /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 6bd57741d39e62d9f16b4d3f408acd0c3dc0f331..a4e4b7e958808b7aed0ecd8cd5c9ae6d1ec81f03 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 ba969dbab53e8dc9f13d67a30d84c45d5e31d657..7b224d4050f08d79b81ded276471a3b97e4a5686 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 a58004d6b03d5ff229448f0244f20e238e3aa775..44679c259cae5eb500dfbe0e8347eb55c0d72eb1 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 f66f875bbfa6c9925ebaf656d0296a52e7458377..4dce7954acee92a1bf37b2f1a260965f9216124e 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 885865af5c4d0ac201b5df3c53bfcacd76921947..fae3a9843b02175774c771ba4f06bff760df4d31 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 ccb5ed6ec6a3aa620fdf5b97c87a044e66125513..9b124da0c73ac81241152c9c42b5974340d34425 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 ebce6f9c29d3cae85a64fc43b5f93443d9ede13e..fbd3031c9d1f091e85e1be3f06f914669974a710 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 ef161c163929e32a4d5794a93ba1ab3cad80568a..61b3a56af4cb4a4434a6c0fc4b7f04ae53eda950 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 264bbaf90835f11fbf6ad518b6f89211aad6af7f..a606dbc82a6d592e699d0007a7419bd26929483e 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 ad2db8a2a7ed95961344bb7ac61ca430a47a24c1..cddde01fb8262dce9db404e35e8b29fca38c50f6 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 e952bee82f5bc471e169ec46277343590a420773..e6b6b5f09f3784312987179f04f4d679e8afcdf7 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 a237e6889283e6fdf30e2adb11ce1e8c56877720..4582a9382096859523bc42c15d9f9ceaed3d8c79 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 5e5fa3d48dfcfda9c4d5be5f7abf2a4e88337fc4..6327fbf44d2034afb9f044c366aff30521de3608 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 945c245e97f7b61f10850bd9357975406d25b6ac..549ce86d2561baa0318fcce74b51ec9295c938ef 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 b88ea2c5e3fffc934aec534cbbbb7ba005862dc2..56c022f8e09c011387c2cde6aaf891ad199bb153 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 0000000000000000000000000000000000000000..54bd0ab9e08e80cc6bb822204a1eae29c6d59d60 --- /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 05a612c0c07d6f7b4e92f95f4b236053518a219d..f663e461c8c95d82c7f3eb44237ef4c317499205 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(); + }); }); }); - }); + } }); });