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

Fix tests for attribute links

parent c8165b27
No related branches found
No related tags found
No related merge requests found
Showing
with 61 additions and 46 deletions
......@@ -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'));
......
......
# What is Abstract?
Something that cannot be instantiated.
......@@ -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
......
......
......@@ -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
......
......
......@@ -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
......
......
......@@ -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
......
......
......@@ -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
......
......
......@@ -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
......
......
......@@ -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
......
......
......@@ -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
......
......
......@@ -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
......
......
......@@ -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
......
......
......@@ -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
......
......
......@@ -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
......
......
......@@ -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
......
......
......@@ -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
......
......
......@@ -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
......
......
......@@ -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
......
......
# Status
We know multiple stati
......@@ -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() {
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment