From f7249ae88c0057542270d84539d0011280d9c82b Mon Sep 17 00:00:00 2001
From: Lars Trieloff <trieloff@adobe.com>
Date: Wed, 25 Apr 2018 14:11:14 +0000
Subject: [PATCH] Basic testing for `@id` prperty
---
examples/docs/README.md | 22 ----------------------
examples/docs/abstract.schema.md | 6 +++---
examples/docs/arrays.schema.md | 6 +++---
examples/docs/complex.schema.md | 6 +++---
examples/docs/constants.schema.md | 6 +++---
examples/docs/custom.schema.md | 6 +++---
examples/docs/deepextending.schema.md | 6 +++---
examples/docs/definitions.schema.md | 6 +++---
examples/docs/enums.schema.md | 6 +++---
examples/docs/example.schema.md | 6 +++---
examples/docs/examples.schema.md | 6 +++---
examples/docs/extending.schema.md | 6 +++---
examples/docs/extensible.schema.md | 6 +++---
examples/docs/simple.schema.md | 6 +++---
examples/docs/simpletypes.schema.md | 6 +++---
examples/docs/stabilizing.schema.md | 6 +++---
examples/docs/subdir/subdir.schema.md | 6 +++---
examples/schemas/extending.schema.json | 2 +-
lib/header.js | 12 ++++++++++++
spec/lib/header.spec.js | 6 +++---
20 files changed, 64 insertions(+), 74 deletions(-)
diff --git a/examples/docs/README.md b/examples/docs/README.md
index 896a8a1..fbbb817 100644
--- a/examples/docs/README.md
+++ b/examples/docs/README.md
@@ -3,25 +3,3 @@
# 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/examples/docs/abstract.schema.md b/examples/docs/abstract.schema.md
index a4e4b7e..fdd7b67 100644
--- a/examples/docs/abstract.schema.md
+++ b/examples/docs/abstract.schema.md
@@ -11,9 +11,9 @@ https://example.com/schemas/abstract
This is an abstract schema. It has `definitions`, but does not declare any properties
-| [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](../abstract.md) | Extensible | [Status](../status.md) | Identifiable | Custom Properties | Additional Properties | Defined In |
+|----------------------------|------------|------------------------|--------------|-------------------|-----------------------|------------|
+| Cannot be instantiated | Yes | Experimental | No | 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 7b224d4..15d3d81 100644
--- a/examples/docs/arrays.schema.md
+++ b/examples/docs/arrays.schema.md
@@ -11,9 +11,9 @@ https://example.com/schemas/arrays
This is an example schema with examples for multiple array types and their constraints.
-| [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) |
+| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Identifiable | Custom Properties | Additional Properties | Defined In |
+|----------------------------|------------|------------------------|--------------|-------------------|-----------------------|------------|
+| Can be instantiated | No | Experimental | No | 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 44679c2..1a04dcd 100644
--- a/examples/docs/complex.schema.md
+++ b/examples/docs/complex.schema.md
@@ -11,9 +11,9 @@ https://example.com/schemas/complex
This is an example schema that uses types defined in other schemas.
-| [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) |
+| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Identifiable | Custom Properties | Additional Properties | Defined In |
+|----------------------------|------------|------------------------|--------------|-------------------|-----------------------|------------|
+| Can be instantiated | No | Experimental | No | Forbidden | Permitted | [complex.schema.json](complex.schema.json) |
## Schema Hierarchy
* Complex References `https://example.com/schemas/complex`
diff --git a/examples/docs/constants.schema.md b/examples/docs/constants.schema.md
index 4dce795..cf4c387 100644
--- a/examples/docs/constants.schema.md
+++ b/examples/docs/constants.schema.md
@@ -11,9 +11,9 @@ https://example.com/schemas/constants
This is an example schema with examples for properties with constant values
-| [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) |
+| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Identifiable | Custom Properties | Additional Properties | Defined In |
+|----------------------------|------------|------------------------|--------------|-------------------|-----------------------|------------|
+| Can be instantiated | No | Experimental | No | 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 fae3a98..d2971e1 100644
--- a/examples/docs/custom.schema.md
+++ b/examples/docs/custom.schema.md
@@ -11,9 +11,9 @@ 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](../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) |
+| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Identifiable | Custom Properties | Additional Properties | Defined In |
+|----------------------------|------------|------------------------|--------------|-------------------|-----------------------|------------|
+| Can be instantiated | Yes | Experimental | No | 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 3c1fc44..0878dff 100644
--- a/examples/docs/deepextending.schema.md
+++ b/examples/docs/deepextending.schema.md
@@ -11,9 +11,9 @@ https://example.com/schemas/deepextending
This is an extending schema. It is extending another extending schema. It pulls `definitions` from other schemas.
-| [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) |
+| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Identifiable | Custom Properties | Additional Properties | Defined In |
+|----------------------------|------------|------------------------|--------------|-------------------|-----------------------|------------|
+| Can be instantiated | Yes | Experimental | No | Forbidden | Permitted | [deepextending.schema.json](deepextending.schema.json) |
## Schema Hierarchy
* Deeply Extending `https://example.com/schemas/deepextending`
diff --git a/examples/docs/definitions.schema.md b/examples/docs/definitions.schema.md
index 97bceaa..f05804a 100644
--- a/examples/docs/definitions.schema.md
+++ b/examples/docs/definitions.schema.md
@@ -28,9 +28,9 @@ aks.
> Everything is better with a quote.
-| [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) |
+| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Identifiable | Custom Properties | Additional Properties | Defined In |
+|----------------------------|------------|------------------------|--------------|-------------------|-----------------------|------------|
+| Can be instantiated | Yes | Experimental | No | 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 61b3a56..3b4ea10 100644
--- a/examples/docs/enums.schema.md
+++ b/examples/docs/enums.schema.md
@@ -11,9 +11,9 @@ https://example.com/schemas/enums
This is an example schema with examples for properties with enum values
-| [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) |
+| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Identifiable | Custom Properties | Additional Properties | Defined In |
+|----------------------------|------------|------------------------|--------------|-------------------|-----------------------|------------|
+| Can be instantiated | No | Experimental | No | 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 a606dbc..39a7d67 100644
--- a/examples/docs/example.schema.md
+++ b/examples/docs/example.schema.md
@@ -11,9 +11,9 @@ https://example.com/schemas/example
This is an example schema with examples. Too many examples? There can never be too many examples!
-| [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) |
+| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Identifiable | Custom Properties | Additional Properties | Defined In |
+|----------------------------|------------|------------------------|--------------|-------------------|-----------------------|------------|
+| Can be instantiated | No | Experimental | No | Forbidden | Permitted | [example.schema.json](example.schema.json) |
## Example Example
```json
diff --git a/examples/docs/examples.schema.md b/examples/docs/examples.schema.md
index cddde01..5d4aa2c 100644
--- a/examples/docs/examples.schema.md
+++ b/examples/docs/examples.schema.md
@@ -11,9 +11,9 @@ https://example.com/schemas/examples
This is an example schema with *multiple* examples. Too many examples? There can never be too many examples!
-| [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) |
+| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Identifiable | Custom Properties | Additional Properties | Defined In |
+|----------------------------|------------|------------------------|--------------|-------------------|-----------------------|------------|
+| Can be instantiated | No | Experimental | No | 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 a34d9c6..77314a3 100644
--- a/examples/docs/extending.schema.md
+++ b/examples/docs/extending.schema.md
@@ -11,9 +11,9 @@ https://example.com/schemas/extending
This is an extending schema. It pulls `definitions` from other schemas.
-| [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) |
+| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Identifiable | Custom Properties | Additional Properties | Defined In |
+|----------------------------|------------|------------------------|--------------|-------------------|-----------------------|------------|
+| Can be instantiated | Yes | Experimental | No | Forbidden | Permitted | [extending.schema.json](extending.schema.json) |
## Schema Hierarchy
* Extending `https://example.com/schemas/extending`
diff --git a/examples/docs/extensible.schema.md b/examples/docs/extensible.schema.md
index 4582a93..edf1e5c 100644
--- a/examples/docs/extensible.schema.md
+++ b/examples/docs/extensible.schema.md
@@ -11,9 +11,9 @@ https://example.com/schemas/extensible
This is an extensible schema. It has `definitions`, that can be used in other schemas
-| [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) |
+| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Identifiable | Custom Properties | Additional Properties | Defined In |
+|----------------------------|------------|------------------------|--------------|-------------------|-----------------------|------------|
+| Cannot be instantiated | Yes | Experimental | No | 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 6327fbf..b801c02 100644
--- a/examples/docs/simple.schema.md
+++ b/examples/docs/simple.schema.md
@@ -11,9 +11,9 @@ https://example.com/schemas/simple
This is a *very* simple example of a JSON schema. There is only one property.
-| [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) |
+| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Identifiable | Custom Properties | Additional Properties | Defined In |
+|----------------------------|------------|------------------------|--------------|-------------------|-----------------------|------------|
+| Can be instantiated | No | Experimental | No | 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 6e89018..b030c5a 100644
--- a/examples/docs/simpletypes.schema.md
+++ b/examples/docs/simpletypes.schema.md
@@ -11,9 +11,9 @@ https://example.com/schemas/simpletypes
This is an example schema with examples for multiple types and their constraints.
-| [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) |
+| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Identifiable | Custom Properties | Additional Properties | Defined In |
+|----------------------------|------------|------------------------|--------------|-------------------|-----------------------|------------|
+| Can be instantiated | No | Experimental | No | 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 56c022f..cc1a082 100644
--- a/examples/docs/stabilizing.schema.md
+++ b/examples/docs/stabilizing.schema.md
@@ -11,9 +11,9 @@ https://example.com/schemas/stabilizing
This is a schema which is currently in the `stabilizing` status.
-| [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) |
+| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Identifiable | Custom Properties | Additional Properties | Defined In |
+|----------------------------|------------|------------------------|--------------|-------------------|-----------------------|------------|
+| Can be instantiated | No | Stabilizing | No | 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 54bd0ab..259b69e 100644
--- a/examples/docs/subdir/subdir.schema.md
+++ b/examples/docs/subdir/subdir.schema.md
@@ -11,9 +11,9 @@ 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) |
+| [Abstract](../../abstract.md) | Extensible | [Status](../../status.md) | Identifiable | Custom Properties | Additional Properties | Defined In |
+|-------------------------------|------------|---------------------------|--------------|-------------------|-----------------------|------------|
+| Cannot be instantiated | Yes | Experimental | No | Forbidden | Permitted | [subdir/subdir.schema.json](subdir/subdir.schema.json) |
# Subdir Definitions
diff --git a/examples/schemas/extending.schema.json b/examples/schemas/extending.schema.json
index 5056f53..5d13224 100644
--- a/examples/schemas/extending.schema.json
+++ b/examples/schemas/extending.schema.json
@@ -32,4 +32,4 @@
{ "$ref": "https://example.com/schemas/definitions#/definitions/myid" },
{ "$ref": "#/definitions/third" }
]
-}
\ No newline at end of file
+}
diff --git a/lib/header.js b/lib/header.js
index e20c200..215bbd3 100644
--- a/lib/header.js
+++ b/lib/header.js
@@ -83,6 +83,17 @@ function link(indir, filename, inlink) {
}
}
+function isIdentifiable(schema) {
+ if (!schema.properties) {
+ return 'Unknown';
+ }
+ if (schema.properties['@id']&&schema.properties['@id'].type==='string'&&schema.properties['@id'].format==='uri') {
+ return 'Yes';
+ } else {
+ return 'No';
+ }
+}
+
function headers(schema, indir, filename, docs, outdir) {
const props = schemaProps(schema, indir, filename);
this.doclinks = docs ? docs : {};
@@ -91,6 +102,7 @@ function headers(schema, indir, filename, docs, outdir) {
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('Identifiable', link(indir, filename, this.doclinks['id']), isIdentifiable(schema)));
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));
diff --git a/spec/lib/header.spec.js b/spec/lib/header.spec.js
index 547fd4c..194cdd9 100644
--- a/spec/lib/header.spec.js
+++ b/spec/lib/header.spec.js
@@ -39,9 +39,9 @@ describe('Headers Integration Test', () => {
const h = headers(schema, '/home/lars', '/home/lars/complex.schema.json');
- const result = `| Abstract | Extensible | Status | Custom Properties | Additional Properties | Defined In |
-|----------|------------|--------|-------------------|-----------------------|------------|
-| Can be instantiated | No | Experimental | Forbidden | Permitted | [complex.schema.json](complex.schema.json) |`;
+ const result = `| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Defined In |
+|----------|------------|--------|--------------|-------------------|-----------------------|------------|
+| Can be instantiated | No | Experimental | No | Forbidden | Permitted | [complex.schema.json](complex.schema.json) |`;
expect(h.render()).toEqual(result);
});
--
GitLab