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

show when additional properties are allowed, fixes #19

parent 9c07487b
Branches
Tags
No related merge requests found
Showing
with 57 additions and 52 deletions
...@@ -11,9 +11,9 @@ https://example.com/schemas/abstract ...@@ -11,9 +11,9 @@ https://example.com/schemas/abstract
This is an abstract schema. It has `definitions`, but does not declare any properties This is an abstract schema. It has `definitions`, but does not declare any properties
| Abstract | Extensible | Custom Properties | Defined In | | Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
|----------|------------|-------------------|------------| |----------|------------|-------------------|-----------------------|------------|
| Cannot be instantiated | Yes | Forbidden | [abstract.schema.json](abstract.schema.json) | | Cannot be instantiated | Yes | Forbidden | Permitted | [abstract.schema.json](abstract.schema.json) |
# Abstract Definitions # Abstract Definitions
......
...@@ -11,9 +11,9 @@ https://example.com/schemas/arrays ...@@ -11,9 +11,9 @@ https://example.com/schemas/arrays
This is an example schema with examples for multiple array types and their constraints. This is an example schema with examples for multiple array types and their constraints.
| Abstract | Extensible | Custom Properties | Defined In | | Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
|----------|------------|-------------------|------------| |----------|------------|-------------------|-----------------------|------------|
| Can be instantiated | No | Forbidden | [arrays.schema.json](arrays.schema.json) | | Can be instantiated | No | Forbidden | Permitted | [arrays.schema.json](arrays.schema.json) |
# Arrays Properties # Arrays Properties
......
...@@ -11,9 +11,9 @@ https://example.com/schemas/complex ...@@ -11,9 +11,9 @@ https://example.com/schemas/complex
This is an example schema that uses types defined in other schemas. This is an example schema that uses types defined in other schemas.
| Abstract | Extensible | Custom Properties | Defined In | | Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
|----------|------------|-------------------|------------| |----------|------------|-------------------|-----------------------|------------|
| Can be instantiated | No | Forbidden | [complex.schema.json](complex.schema.json) | | Can be instantiated | No | Forbidden | Forbidden | [complex.schema.json](complex.schema.json) |
## Schema Hierarchy ## Schema Hierarchy
...@@ -31,6 +31,7 @@ This is an example schema that uses types defined in other schemas. ...@@ -31,6 +31,7 @@ This is an example schema that uses types defined in other schemas.
| [reflist](#reflist) | Simple | Optional | Complex References (this schema) | | [reflist](#reflist) | Simple | Optional | Complex References (this schema) |
| [refnamed](#refnamed) | Simple | Optional | Complex References (this schema) | | [refnamed](#refnamed) | Simple | Optional | Complex References (this schema) |
| [xor](#xor) | complex | Optional | Complex References (this schema) | | [xor](#xor) | complex | Optional | Complex References (this schema) |
| `*` | `any` | Optional | this schema *allows* additional properties |
## and ## and
......
...@@ -11,9 +11,9 @@ https://example.com/schemas/constants ...@@ -11,9 +11,9 @@ https://example.com/schemas/constants
This is an example schema with examples for properties with constant values This is an example schema with examples for properties with constant values
| Abstract | Extensible | Custom Properties | Defined In | | Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
|----------|------------|-------------------|------------| |----------|------------|-------------------|-----------------------|------------|
| Can be instantiated | No | Forbidden | [constants.schema.json](constants.schema.json) | | Can be instantiated | No | Forbidden | Permitted | [constants.schema.json](constants.schema.json) |
# Constant Types Properties # Constant Types Properties
......
...@@ -11,9 +11,9 @@ https://example.com/schemas/custom ...@@ -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. 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 | | Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
|----------|------------|-------------------|------------| |----------|------------|-------------------|-----------------------|------------|
| Can be instantiated | Yes | Allowed | [custom.schema.json](custom.schema.json) | | Can be instantiated | Yes | Allowed | Permitted | [custom.schema.json](custom.schema.json) |
# Custom Properties # Custom Properties
......
...@@ -11,9 +11,9 @@ https://example.com/schemas/deepextending ...@@ -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. This is an extending schema. It is extending another extending schema. It pulls `definitions` from other schemas.
| Abstract | Extensible | Custom Properties | Defined In | | Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
|----------|------------|-------------------|------------| |----------|------------|-------------------|-----------------------|------------|
| Can be instantiated | Yes | Forbidden | [deepextending.schema.json](deepextending.schema.json) | | Can be instantiated | Yes | Forbidden | Permitted | [deepextending.schema.json](deepextending.schema.json) |
## Schema Hierarchy ## Schema Hierarchy
......
...@@ -25,9 +25,9 @@ Bre- ...@@ -25,9 +25,9 @@ Bre-
aks. aks.
| Abstract | Extensible | Custom Properties | Defined In | | Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
|----------|------------|-------------------|------------| |----------|------------|-------------------|-----------------------|------------|
| Can be instantiated | Yes | Forbidden | [definitions.schema.json](definitions.schema.json) | | Can be instantiated | Yes | Forbidden | Permitted | [definitions.schema.json](definitions.schema.json) |
# Definitions Properties # Definitions Properties
......
...@@ -11,9 +11,9 @@ https://example.com/schemas/enums ...@@ -11,9 +11,9 @@ https://example.com/schemas/enums
This is an example schema with examples for properties with enum values This is an example schema with examples for properties with enum values
| Abstract | Extensible | Custom Properties | Defined In | | Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
|----------|------------|-------------------|------------| |----------|------------|-------------------|-----------------------|------------|
| Can be instantiated | No | Forbidden | [enums.schema.json](enums.schema.json) | | Can be instantiated | No | Forbidden | Permitted | [enums.schema.json](enums.schema.json) |
# Enumerated Properties # Enumerated Properties
......
...@@ -11,9 +11,9 @@ https://example.com/schemas/example ...@@ -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! This is an example schema with examples. Too many examples? There can never be too many examples!
| Abstract | Extensible | Custom Properties | Defined In | | Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
|----------|------------|-------------------|------------| |----------|------------|-------------------|-----------------------|------------|
| Can be instantiated | No | Forbidden | [example.schema.json](example.schema.json) | | Can be instantiated | No | Forbidden | Permitted | [example.schema.json](example.schema.json) |
## Example Example ## Example Example
```json ```json
......
...@@ -11,9 +11,9 @@ https://example.com/schemas/examples ...@@ -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! This is an example schema with *multiple* examples. Too many examples? There can never be too many examples!
| Abstract | Extensible | Custom Properties | Defined In | | Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
|----------|------------|-------------------|------------| |----------|------------|-------------------|-----------------------|------------|
| Can be instantiated | No | Forbidden | [examples.schema.json](examples.schema.json) | | Can be instantiated | No | Forbidden | Permitted | [examples.schema.json](examples.schema.json) |
## Examples Examples ## Examples Examples
......
...@@ -11,9 +11,9 @@ https://example.com/schemas/extending ...@@ -11,9 +11,9 @@ https://example.com/schemas/extending
This is an extending schema. It pulls `definitions` from other schemas. This is an extending schema. It pulls `definitions` from other schemas.
| Abstract | Extensible | Custom Properties | Defined In | | Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
|----------|------------|-------------------|------------| |----------|------------|-------------------|-----------------------|------------|
| Can be instantiated | Yes | Forbidden | [extending.schema.json](extending.schema.json) | | Can be instantiated | Yes | Forbidden | Permitted | [extending.schema.json](extending.schema.json) |
## Schema Hierarchy ## Schema Hierarchy
......
...@@ -11,9 +11,9 @@ https://example.com/schemas/extensible ...@@ -11,9 +11,9 @@ https://example.com/schemas/extensible
This is an extensible schema. It has `definitions`, that can be used in other schemas This is an extensible schema. It has `definitions`, that can be used in other schemas
| Abstract | Extensible | Custom Properties | Defined In | | Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
|----------|------------|-------------------|------------| |----------|------------|-------------------|-----------------------|------------|
| Cannot be instantiated | Yes | Forbidden | [extensible.schema.json](extensible.schema.json) | | Cannot be instantiated | Yes | Forbidden | Permitted | [extensible.schema.json](extensible.schema.json) |
# Extensible Definitions # Extensible Definitions
......
...@@ -11,9 +11,9 @@ https://example.com/schemas/simple ...@@ -11,9 +11,9 @@ https://example.com/schemas/simple
This is a *very* simple example of a JSON schema. There is only one property. This is a *very* simple example of a JSON schema. There is only one property.
| Abstract | Extensible | Custom Properties | Defined In | | Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
|----------|------------|-------------------|------------| |----------|------------|-------------------|-----------------------|------------|
| Can be instantiated | No | Forbidden | [simple.schema.json](simple.schema.json) | | Can be instantiated | No | Forbidden | Permitted | [simple.schema.json](simple.schema.json) |
# Simple Properties # Simple Properties
......
...@@ -11,9 +11,9 @@ https://example.com/schemas/simpletypes ...@@ -11,9 +11,9 @@ https://example.com/schemas/simpletypes
This is an example schema with examples for multiple types and their constraints. This is an example schema with examples for multiple types and their constraints.
| Abstract | Extensible | Custom Properties | Defined In | | Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
|----------|------------|-------------------|------------| |----------|------------|-------------------|-----------------------|------------|
| Can be instantiated | No | Forbidden | [simpletypes.schema.json](simpletypes.schema.json) | | Can be instantiated | No | Forbidden | Permitted | [simpletypes.schema.json](simpletypes.schema.json) |
# Simple Types Properties # Simple Types Properties
......
...@@ -11,9 +11,9 @@ https://example.com/schemas/subdir/subdir ...@@ -11,9 +11,9 @@ https://example.com/schemas/subdir/subdir
A schema in a sub directory A schema in a sub directory
| Abstract | Extensible | Custom Properties | Defined In | | Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
|----------|------------|-------------------|------------| |----------|------------|-------------------|-----------------------|------------|
| Cannot be instantiated | Yes | Forbidden | [subdir/subdir.schema.json](subdir/subdir.schema.json) | | Cannot be instantiated | Yes | Forbidden | Permitted | [subdir/subdir.schema.json](subdir/subdir.schema.json) |
# Subdir Definitions # Subdir Definitions
......
...@@ -64,5 +64,6 @@ ...@@ -64,5 +64,6 @@
}, },
"required": [ "required": [
"refabstract" "refabstract"
] ],
"additionalProperties": true
} }
\ No newline at end of file
...@@ -47,5 +47,6 @@ ...@@ -47,5 +47,6 @@
}, },
"required": [ "required": [
"refabstract" "refabstract"
] ],
"additionalProperties": true
} }
...@@ -172,7 +172,7 @@ const generateMarkdown = function(filename, schema, schemaPath, outDir, dependen ...@@ -172,7 +172,7 @@ const generateMarkdown = function(filename, schema, schemaPath, outDir, dependen
]; ];
if (_.keys(schema.properties).length > 0) { 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++) { for (let i=0; i<_.keys(schema.properties).length;i++) {
const name = _.keys(schema.properties).sort()[i]; const name = _.keys(schema.properties).sort()[i];
multi.push( [ 'property.ejs', { multi.push( [ 'property.ejs', {
......
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
| Abstract | Extensible | Custom Properties | Defined In | | Abstract | Extensible | Custom Properties | Additional Properties | Defined In |
|----------|------------|-------------------|------------| |----------|------------|-------------------|-----------------------|------------|
| <%=props.abstract %> | <%=props.extensible %> | <%=props.custom %> | [<%=props.original %>](<%=props.original %>) | | <%=props.abstract %> | <%=props.extensible %> | <%=props.custom %> | <%= schema.additionalProperties===true ? "Forbidden" : "Permitted" %> | [<%=props.original %>](<%=props.original %>) |
<% if (dependencies.length > 0) { %> <% if (dependencies.length > 0) { %>
## Schema Hierarchy ## Schema Hierarchy
......
...@@ -18,4 +18,6 @@ ...@@ -18,4 +18,6 @@
%><%= title %> (this schema)<% } %> | %><%= title %> (this schema)<% } %> |
<% <%
}); });
%> %><% if (additional) { %>
\ No newline at end of file | `*` | `any` | Optional | this schema *allows* additional properties |
<% } %>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment