From 6cd2231a871a33289e979d80d5b0e37dcf154a01 Mon Sep 17 00:00:00 2001
From: Lars Trieloff <trieloff@adobe.com>
Date: Fri, 5 Jan 2018 15:46:08 +0000
Subject: [PATCH] show when additional properties are allowed, fixes #19

---
 examples/docs/abstract.schema.md               | 6 +++---
 examples/docs/arrays.schema.md                 | 6 +++---
 examples/docs/complex.schema.md                | 7 ++++---
 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/subdir/subdir.schema.md          | 6 +++---
 examples/generated-schemas/complex.schema.json | 3 ++-
 examples/schemas/complex.schema.json           | 3 ++-
 lib/markdownWriter.js                          | 2 +-
 templates/md/header.ejs                        | 6 +++---
 templates/md/properties.ejs                    | 4 +++-
 20 files changed, 57 insertions(+), 52 deletions(-)

diff --git a/examples/docs/abstract.schema.md b/examples/docs/abstract.schema.md
index 5fb46d7..72799ba 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 | Extensible | Custom Properties | Defined In |
-|----------|------------|-------------------|------------|
-| Cannot be instantiated | Yes | Forbidden | [abstract.schema.json](abstract.schema.json) |
+| Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
+|----------|------------|-------------------|-----------------------|------------|
+| Cannot be instantiated | Yes | 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 5b8b85e..33a352c 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 | Extensible | Custom Properties | Defined In |
-|----------|------------|-------------------|------------|
-| Can be instantiated | No | Forbidden | [arrays.schema.json](arrays.schema.json) |
+| Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
+|----------|------------|-------------------|-----------------------|------------|
+| Can be instantiated | 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 f7de9cf..bf4b714 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 | Extensible | Custom Properties | Defined In |
-|----------|------------|-------------------|------------|
-| Can be instantiated | No | Forbidden | [complex.schema.json](complex.schema.json) |
+| Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
+|----------|------------|-------------------|-----------------------|------------|
+| Can be instantiated | No | Forbidden | Forbidden | [complex.schema.json](complex.schema.json) |
 
 ## Schema Hierarchy
 
@@ -31,6 +31,7 @@ This is an example schema that uses types defined in other schemas.
 | [reflist](#reflist) | Simple | Optional | Complex References  (this schema) |
 | [refnamed](#refnamed) | Simple | Optional | Complex References  (this schema) |
 | [xor](#xor) | complex | Optional | Complex References  (this schema) |
+| `*` | `any` | Optional | this schema *allows* additional properties |
 
 ## and
 
diff --git a/examples/docs/constants.schema.md b/examples/docs/constants.schema.md
index 518253c..8c4ef92 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 | Extensible | Custom Properties | Defined In |
-|----------|------------|-------------------|------------|
-| Can be instantiated | No | Forbidden | [constants.schema.json](constants.schema.json) |
+| Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
+|----------|------------|-------------------|-----------------------|------------|
+| Can be instantiated | 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 de9cb64..c6561e0 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 | Extensible | Custom Properties | Defined In |
-|----------|------------|-------------------|------------|
-| Can be instantiated | Yes | Allowed | [custom.schema.json](custom.schema.json) |
+| Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
+|----------|------------|-------------------|-----------------------|------------|
+| Can be instantiated | Yes | 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 0221a91..58b7472 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 | Extensible | Custom Properties | Defined In |
-|----------|------------|-------------------|------------|
-| Can be instantiated | Yes | Forbidden | [deepextending.schema.json](deepextending.schema.json) |
+| Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
+|----------|------------|-------------------|-----------------------|------------|
+| Can be instantiated | Yes | 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 3b73086..7c63cbe 100644
--- a/examples/docs/definitions.schema.md
+++ b/examples/docs/definitions.schema.md
@@ -25,9 +25,9 @@ Bre-
 
 aks.
 
-| Abstract | Extensible | Custom Properties | Defined In |
-|----------|------------|-------------------|------------|
-| Can be instantiated | Yes | Forbidden | [definitions.schema.json](definitions.schema.json) |
+| Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
+|----------|------------|-------------------|-----------------------|------------|
+| Can be instantiated | Yes | 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 d3d0ded..338ad01 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 | Extensible | Custom Properties | Defined In |
-|----------|------------|-------------------|------------|
-| Can be instantiated | No | Forbidden | [enums.schema.json](enums.schema.json) |
+| Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
+|----------|------------|-------------------|-----------------------|------------|
+| Can be instantiated | 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 a72db96..8fff9dc 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 | Extensible | Custom Properties | Defined In |
-|----------|------------|-------------------|------------|
-| Can be instantiated | No | Forbidden | [example.schema.json](example.schema.json) |
+| Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
+|----------|------------|-------------------|-----------------------|------------|
+| Can be instantiated | 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 6195d44..68cfc6f 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 | Extensible | Custom Properties | Defined In |
-|----------|------------|-------------------|------------|
-| Can be instantiated | No | Forbidden | [examples.schema.json](examples.schema.json) |
+| Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
+|----------|------------|-------------------|-----------------------|------------|
+| Can be instantiated | 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 141f234..2643d90 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 | Extensible | Custom Properties | Defined In |
-|----------|------------|-------------------|------------|
-| Can be instantiated | Yes | Forbidden | [extending.schema.json](extending.schema.json) |
+| Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
+|----------|------------|-------------------|-----------------------|------------|
+| Can be instantiated | Yes | 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 d0f9c80..2c7b0eb 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 | Extensible | Custom Properties | Defined In |
-|----------|------------|-------------------|------------|
-| Cannot be instantiated | Yes | Forbidden | [extensible.schema.json](extensible.schema.json) |
+| Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
+|----------|------------|-------------------|-----------------------|------------|
+| Cannot be instantiated | Yes | 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 bdaa1ea..8669734 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 | Extensible | Custom Properties | Defined In |
-|----------|------------|-------------------|------------|
-| Can be instantiated | No | Forbidden | [simple.schema.json](simple.schema.json) |
+| Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
+|----------|------------|-------------------|-----------------------|------------|
+| Can be instantiated | 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 00b71c2..92351c2 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 | Extensible | Custom Properties | Defined In |
-|----------|------------|-------------------|------------|
-| Can be instantiated | No | Forbidden | [simpletypes.schema.json](simpletypes.schema.json) |
+| Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
+|----------|------------|-------------------|-----------------------|------------|
+| Can be instantiated | No | Forbidden | Permitted | [simpletypes.schema.json](simpletypes.schema.json) |
 
 # Simple Types Properties
 
diff --git a/examples/docs/subdir/subdir.schema.md b/examples/docs/subdir/subdir.schema.md
index b62f222..ab876d4 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 | Extensible | Custom Properties | Defined In |
-|----------|------------|-------------------|------------|
-| Cannot be instantiated | Yes | Forbidden | [subdir/subdir.schema.json](subdir/subdir.schema.json) |
+| Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
+|----------|------------|-------------------|-----------------------|------------|
+| Cannot be instantiated | Yes | Forbidden | Permitted | [subdir/subdir.schema.json](subdir/subdir.schema.json) |
 
 # Subdir Definitions
 
diff --git a/examples/generated-schemas/complex.schema.json b/examples/generated-schemas/complex.schema.json
index ffab75e..bfac128 100644
--- a/examples/generated-schemas/complex.schema.json
+++ b/examples/generated-schemas/complex.schema.json
@@ -64,5 +64,6 @@
     },
     "required": [
         "refabstract"
-    ]
+    ],
+    "additionalProperties": true
 }
\ No newline at end of file
diff --git a/examples/schemas/complex.schema.json b/examples/schemas/complex.schema.json
index 53eb440..1ed3314 100644
--- a/examples/schemas/complex.schema.json
+++ b/examples/schemas/complex.schema.json
@@ -47,5 +47,6 @@
   },
   "required": [
     "refabstract"
-  ]
+  ],
+  "additionalProperties": true
 }
diff --git a/lib/markdownWriter.js b/lib/markdownWriter.js
index 8cd6a39..6ce3a90 100644
--- a/lib/markdownWriter.js
+++ b/lib/markdownWriter.js
@@ -172,7 +172,7 @@ const generateMarkdown = function(filename, schema, schemaPath, outDir, dependen
   ];
 
   if (_.keys(schema.properties).length > 0) {
-    multi.push([ 'properties.ejs', { props: requiredProperties(schema.properties, schema.required), title: schema.title } ]);
+    multi.push([ 'properties.ejs', { props: requiredProperties(schema.properties, schema.required), title: schema.title, additional: schema.additionalProperties } ]);
     for (let i=0; i<_.keys(schema.properties).length;i++) {
       const name = _.keys(schema.properties).sort()[i];
       multi.push( [ 'property.ejs', {
diff --git a/templates/md/header.ejs b/templates/md/header.ejs
index 56d68ab..1871e1b 100644
--- a/templates/md/header.ejs
+++ b/templates/md/header.ejs
@@ -16,9 +16,9 @@
 
 
 
-| Abstract | Extensible | Custom Properties | Defined In |
-|----------|------------|-------------------|------------|
-| <%=props.abstract %> | <%=props.extensible %> | <%=props.custom %> | [<%=props.original %>](<%=props.original %>) |
+| Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
+|----------|------------|-------------------|-----------------------|------------|
+| <%=props.abstract %> | <%=props.extensible %> | <%=props.custom %> | <%= schema.additionalProperties===true ? "Forbidden" : "Permitted"  %> | [<%=props.original %>](<%=props.original %>) |
 
 <% if (dependencies.length > 0) { %>
 ## Schema Hierarchy
diff --git a/templates/md/properties.ejs b/templates/md/properties.ejs
index 0a52119..f248774 100644
--- a/templates/md/properties.ejs
+++ b/templates/md/properties.ejs
@@ -18,4 +18,6 @@
       %><%= title %> (this schema)<% } %> |
 <%
 });
-%>
\ No newline at end of file
+%><% if (additional) { %>
+| `*` | `any` | Optional | this schema *allows* additional properties |
+<% } %>
\ No newline at end of file
-- 
GitLab