diff --git a/examples/docs/README.md b/examples/docs/README.md index cbf8be85683526a0b9ddbc90a9d00def620cb003..f6545c105f0a04557bc1922d27e2fcfe747da6e6 100644 --- a/examples/docs/README.md +++ b/examples/docs/README.md @@ -22,6 +22,7 @@ * [Simple](./simple.schema.md) – `https://example.com/schemas/simple` (Unknown) * [Simple Types](./simpletypes.schema.md) – `https://example.com/schemas/simpletypes` (Unknown) * [Stabilizing](./stabilizing.schema.md) – `https://example.com/schemas/stabilizing` (Stabilizing) +* [Type Arrays](./typearrays.schema.md) – `https://example.com/schemas/typearrays` (Unknown) ## /subdir/ diff --git a/examples/docs/arrays.schema.md b/examples/docs/arrays.schema.md index 74c7371d70d4b971396de79f67f032f5856ca1ce..4ed3a03d32a8c19c96ba21b9a006583ebd68a5a2 100644 --- a/examples/docs/arrays.schema.md +++ b/examples/docs/arrays.schema.md @@ -17,17 +17,17 @@ This is an example schema with examples for multiple array types and their const # Arrays Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [boollist](#boollist) | `boolean[]` | Optional | Arrays (this schema) | -| [coordinatelist](#coordinatelist) | `number[][]` | Optional | Arrays (this schema) | -| [intlist](#intlist) | `integer[]` | Optional | Arrays (this schema) | -| [list](#list) | `string[]` | Optional | Arrays (this schema) | -| [listlist](#listlist) | `array[]` | Optional | Arrays (this schema) | -| [numlist](#numlist) | `number[]` | Optional | Arrays (this schema) | -| [objectlist](#objectlist) | `object[]` | Optional | Arrays (this schema) | -| [stringlistlist](#stringlistlist) | `string[][]` | Optional | Arrays (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [boollist](#boollist) | `boolean[]` | Optional | No | Arrays (this schema) | +| [coordinatelist](#coordinatelist) | `number[][]` | Optional | No | Arrays (this schema) | +| [intlist](#intlist) | `integer[]` | Optional | No | Arrays (this schema) | +| [list](#list) | `string[]` | Optional | No | Arrays (this schema) | +| [listlist](#listlist) | `array[]` | Optional | No | Arrays (this schema) | +| [numlist](#numlist) | `number[]` | Optional | No | Arrays (this schema) | +| [objectlist](#objectlist) | `object[]` | Optional | No | Arrays (this schema) | +| [stringlistlist](#stringlistlist) | `string[][]` | Optional | No | Arrays (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## boollist diff --git a/examples/docs/complex.schema.md b/examples/docs/complex.schema.md index c813c30a2b0237ed74f602ea640e171cff2bdac2..d1faebd13ee94e79c5ee0f2da7d297ed855460f3 100644 --- a/examples/docs/complex.schema.md +++ b/examples/docs/complex.schema.md @@ -23,17 +23,17 @@ This is an example schema that uses types defined in other schemas. # Complex References Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [and](#and) | complex | Optional | Complex References (this schema) | -| [or](#or) | complex | Optional | Complex References (this schema) | -| [refabstract](#refabstract) | `object` | **Required** | Complex References (this schema) | -| [reflist](#reflist) | Simple | Optional | Complex References (this schema) | -| [refnamed](#refnamed) | Simple | Optional | Complex References (this schema) | -| [xor](#xor) | complex | Optional | Complex References (this schema) | -| `int.*` | `integer` | Pattern | Complex References (this schema) | -| `str.*` | `string` | Pattern | Complex References (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [and](#and) | complex | Optional | No | Complex References (this schema) | +| [or](#or) | complex | Optional | No | Complex References (this schema) | +| [refabstract](#refabstract) | `object` | **Required** | No | Complex References (this schema) | +| [reflist](#reflist) | Simple | Optional | No | Complex References (this schema) | +| [refnamed](#refnamed) | Simple | Optional | No | Complex References (this schema) | +| [xor](#xor) | complex | Optional | No | Complex References (this schema) | +| `int.*` | `integer` | Pattern No | Complex References (this schema) | +| `str.*` | `string` | Pattern No | Complex References (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## and diff --git a/examples/docs/constants.schema.md b/examples/docs/constants.schema.md index cf4c3870e8783b26e91e350fb9c988f41215df13..fb265efec49405c34940c8bc3fc25fdf04e85aa6 100644 --- a/examples/docs/constants.schema.md +++ b/examples/docs/constants.schema.md @@ -17,10 +17,10 @@ This is an example schema with examples for properties with constant values # Constant Types Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [hello](#hello) | `const` | **Required** | Constant Types (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [hello](#hello) | `const` | **Required** | No | Constant Types (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## hello diff --git a/examples/docs/custom.schema.md b/examples/docs/custom.schema.md index d2971e16b2c3fd8449f0b75bc80eac5c4229d552..fda33c9f426a1be000f5c9c9b21c7d1ff2e0f9df 100644 --- a/examples/docs/custom.schema.md +++ b/examples/docs/custom.schema.md @@ -17,11 +17,11 @@ This is an extensible schema. It has `definitions`, that can be used in other sc # Custom Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [bar](#bar) | `string` | Optional | Custom (this schema) | -| [foo](#foo) | `string` | Optional | Custom (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [bar](#bar) | `string` | Optional | No | Custom (this schema) | +| [foo](#foo) | `string` | Optional | No | Custom (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## bar diff --git a/examples/docs/deepextending.schema.md b/examples/docs/deepextending.schema.md index 4ec03594460cfb8dfb90cb8bd45ee3848014cb05..b9f0a69c40d520e9f543c6171cfcec19956cd24f 100644 --- a/examples/docs/deepextending.schema.md +++ b/examples/docs/deepextending.schema.md @@ -24,15 +24,15 @@ This is an extending schema. It is extending another extending schema. It pulls # Deeply Extending Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [@id](#id) | `string` | Optional | [Definitions](definitions.schema.md#id) | -| [bar](#bar) | `string` | Optional | [Extensible](extensible.schema.md#bar) | -| [baz](#baz) | `string` | Optional | [Extending](extending.schema.md#baz) | -| [hey](#hey) | `string` | Optional | Deeply Extending (this schema) | -| [id](#id-1) | `string` | Optional | [Definitions](definitions.schema.md#id-1) | -| [meta:id](#metaid) | `string` | Optional | [Definitions](definitions.schema.md#metaid) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [@id](#id) | `string` | Optional | No | [Definitions](definitions.schema.md#id) | +| [bar](#bar) | `string` | Optional | No | [Extensible](extensible.schema.md#bar) | +| [baz](#baz) | `string` | Optional | No | [Extending](extending.schema.md#baz) | +| [hey](#hey) | `string` | Optional | No | Deeply Extending (this schema) | +| [id](#id-1) | `string` | Optional | No | [Definitions](definitions.schema.md#id-1) | +| [meta:id](#metaid) | `string` | Optional | No | [Definitions](definitions.schema.md#metaid) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## @id diff --git a/examples/docs/definitions.schema.md b/examples/docs/definitions.schema.md index 0054a2ea8b065dffdc76a0e18390be3a6b7b1b7c..325397f7c2a6bde2211add30bda6daa32bfcddd5 100644 --- a/examples/docs/definitions.schema.md +++ b/examples/docs/definitions.schema.md @@ -34,12 +34,12 @@ aks. # Definitions Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [@id](#id) | `string` | Optional | Definitions (this schema) | -| [id](#id-1) | `string` | **Required** | Definitions (this schema) | -| [meta:id](#metaid) | `string` | Optional | Definitions (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [@id](#id) | `string` | Optional | No | Definitions (this schema) | +| [id](#id-1) | `string` | **Required** | No | Definitions (this schema) | +| [meta:id](#metaid) | `string` | Optional | No | Definitions (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## @id diff --git a/examples/docs/enums.schema.md b/examples/docs/enums.schema.md index 93d471654eadb7897b966a61b9482d20f0aadde0..df130568c653206b8d678e4ad6f13efa53e87fd1 100644 --- a/examples/docs/enums.schema.md +++ b/examples/docs/enums.schema.md @@ -17,11 +17,11 @@ This is an example schema with examples for properties with enum values # Enumerated Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [hello](#hello) | `enum` | **Required** | Enumerated (this schema) | -| [nested](#nested) | `object` | Optional | Enumerated (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [hello](#hello) | `enum` | **Required** | No | Enumerated (this schema) | +| [nested](#nested) | `object` | Optional | No | Enumerated (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## hello diff --git a/examples/docs/example.schema.md b/examples/docs/example.schema.md index 39a7d67437492bdde4b4f4185e39440f20a2d0fd..a17b01d64459de577661749a722269a677402bb7 100644 --- a/examples/docs/example.schema.md +++ b/examples/docs/example.schema.md @@ -25,11 +25,11 @@ This is an example schema with examples. Too many examples? There can never be t # Example Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [bar](#bar) | `string` | Optional | Example (this schema) | -| [foo](#foo) | `string` | Optional | Example (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [bar](#bar) | `string` | Optional | No | Example (this schema) | +| [foo](#foo) | `string` | Optional | No | Example (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## bar diff --git a/examples/docs/examples.schema.md b/examples/docs/examples.schema.md index 5d4aa2ca7ebfed62be546e3be03db4211728114f..00b8de4811ae12fb12c1bfa30a29d3eac42709e4 100644 --- a/examples/docs/examples.schema.md +++ b/examples/docs/examples.schema.md @@ -34,11 +34,11 @@ This is an example schema with *multiple* examples. Too many examples? There can # Examples Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [bar](#bar) | `string` | **Required** | Examples (this schema) | -| [foo](#foo) | `string` | Optional | Examples (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [bar](#bar) | `string` | **Required** | No | Examples (this schema) | +| [foo](#foo) | `string` | Optional | No | Examples (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## bar diff --git a/examples/docs/extending.schema.md b/examples/docs/extending.schema.md index bc55d8728ab2bd21963f8cfe51e009bb500fb1d3..178084096524ae84b4a98fefa3aafa4118ba52fc 100644 --- a/examples/docs/extending.schema.md +++ b/examples/docs/extending.schema.md @@ -23,14 +23,14 @@ This is an extending schema. It pulls `definitions` from other schemas. # Extending Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [@id](#id) | `string` | Optional | [Definitions](definitions.schema.md#id) | -| [bar](#bar) | `string` | Optional | [Extensible](extensible.schema.md#bar) | -| [baz](#baz) | `string` | Optional | Extending (this schema) | -| [id](#id-1) | `string` | Optional | [Definitions](definitions.schema.md#id-1) | -| [meta:id](#metaid) | `string` | Optional | [Definitions](definitions.schema.md#metaid) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [@id](#id) | `string` | Optional | No | [Definitions](definitions.schema.md#id) | +| [bar](#bar) | `string` | Optional | No | [Extensible](extensible.schema.md#bar) | +| [baz](#baz) | `string` | Optional | No | Extending (this schema) | +| [id](#id-1) | `string` | Optional | No | [Definitions](definitions.schema.md#id-1) | +| [meta:id](#metaid) | `string` | Optional | No | [Definitions](definitions.schema.md#metaid) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## @id diff --git a/examples/docs/identifiable.schema.md b/examples/docs/identifiable.schema.md index d0dc69e4a00ffed1196ddf4ca847191b8427e317..a3060fc196b1dc9b45cd04aaf179af04b7a1487e 100644 --- a/examples/docs/identifiable.schema.md +++ b/examples/docs/identifiable.schema.md @@ -17,10 +17,10 @@ This is a *very* simple example of a JSON schema. There is only one property. # Identifiable Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [@id](#id) | `string` | Optional | Identifiable (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [@id](#id) | `string` | Optional | No | Identifiable (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## @id diff --git a/examples/docs/simple.schema.md b/examples/docs/simple.schema.md index b801c02f404115e1ccfe9d8e24186df46e6ce035..4d533638fc47c37b450d70d90c98199f110bcbe0 100644 --- a/examples/docs/simple.schema.md +++ b/examples/docs/simple.schema.md @@ -17,10 +17,10 @@ This is a *very* simple example of a JSON schema. There is only one property. # Simple Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [id](#id) | `string` | Optional | Simple (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [id](#id) | `string` | Optional | No | Simple (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## id diff --git a/examples/docs/simpletypes.schema.md b/examples/docs/simpletypes.schema.md index b030c5ad4cb58776086a4d92a35b764a00199f4e..109b8364b5f70aeed0a718c57842ca9e8ae4bd6c 100644 --- a/examples/docs/simpletypes.schema.md +++ b/examples/docs/simpletypes.schema.md @@ -17,26 +17,26 @@ This is an example schema with examples for multiple types and their constraints # Simple Types Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [integer_threes](#integer_threes) | `integer` | Optional | Simple Types (this schema) | -| [interger_constrained](#interger_constrained) | `integer` | Optional | Simple Types (this schema) | -| [interger_unconstrained](#interger_unconstrained) | `integer` | Optional | Simple Types (this schema) | -| [number_constrained](#number_constrained) | `number` | Optional | Simple Types (this schema) | -| [number_unconstrained](#number_unconstrained) | `number` | Optional | Simple Types (this schema) | -| [string_date](#string_date) | `string` | Optional | Simple Types (this schema) | -| [string_email](#string_email) | `string` | Optional | Simple Types (this schema) | -| [string_hostname](#string_hostname) | `string` | Optional | Simple Types (this schema) | -| [string_ipv4](#string_ipv4) | `string` | Optional | Simple Types (this schema) | -| [string_ipv6](#string_ipv6) | `string` | Optional | Simple Types (this schema) | -| [string_length](#string_length) | `string` | Optional | Simple Types (this schema) | -| [string_pattern](#string_pattern) | `string` | Optional | Simple Types (this schema) | -| [string_pattern_noexample](#string_pattern_noexample) | `string` | Optional | Simple Types (this schema) | -| [string_pattern_singleexample](#string_pattern_singleexample) | `string` | Optional | Simple Types (this schema) | -| [string_unconstrained](#string_unconstrained) | `string` | Optional | Simple Types (this schema) | -| [string_uri](#string_uri) | `string` | Optional | Simple Types (this schema) | -| [yesno](#yesno) | `boolean` | **Required** | Simple Types (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [integer_threes](#integer_threes) | `integer` | Optional | No | Simple Types (this schema) | +| [interger_constrained](#interger_constrained) | `integer` | Optional | No | Simple Types (this schema) | +| [interger_unconstrained](#interger_unconstrained) | `integer` | Optional | No | Simple Types (this schema) | +| [number_constrained](#number_constrained) | `number` | Optional | No | Simple Types (this schema) | +| [number_unconstrained](#number_unconstrained) | `number` | Optional | No | Simple Types (this schema) | +| [string_date](#string_date) | `string` | Optional | No | Simple Types (this schema) | +| [string_email](#string_email) | `string` | Optional | No | Simple Types (this schema) | +| [string_hostname](#string_hostname) | `string` | Optional | No | Simple Types (this schema) | +| [string_ipv4](#string_ipv4) | `string` | Optional | No | Simple Types (this schema) | +| [string_ipv6](#string_ipv6) | `string` | Optional | No | Simple Types (this schema) | +| [string_length](#string_length) | `string` | Optional | No | Simple Types (this schema) | +| [string_pattern](#string_pattern) | `string` | Optional | No | Simple Types (this schema) | +| [string_pattern_noexample](#string_pattern_noexample) | `string` | Optional | No | Simple Types (this schema) | +| [string_pattern_singleexample](#string_pattern_singleexample) | `string` | Optional | No | Simple Types (this schema) | +| [string_unconstrained](#string_unconstrained) | `string` | Optional | No | Simple Types (this schema) | +| [string_uri](#string_uri) | `string` | Optional | No | Simple Types (this schema) | +| [yesno](#yesno) | `boolean` | **Required** | No | Simple Types (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## integer_threes diff --git a/examples/docs/stabilizing.schema.md b/examples/docs/stabilizing.schema.md index cc1a08297d82e3ca6e383a8fcb6900b60d2f4403..c98a34674158239db36dfb963669d307604a0654 100644 --- a/examples/docs/stabilizing.schema.md +++ b/examples/docs/stabilizing.schema.md @@ -17,10 +17,10 @@ This is a schema which is currently in the `stabilizing` status. # Stabilizing Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [id](#id) | `string` | Optional | Stabilizing (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [id](#id) | `string` | Optional | No | Stabilizing (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## id diff --git a/examples/docs/typearrays.schema.md b/examples/docs/typearrays.schema.md new file mode 100644 index 0000000000000000000000000000000000000000..a31629bd04ee45532bccd497cdaff72d694ae381 --- /dev/null +++ b/examples/docs/typearrays.schema.md @@ -0,0 +1,104 @@ +--- +template: reference +foo: bar +--- + +# Type Arrays Schema + +``` +https://example.com/schemas/typearrays +``` + +This schema test type arrays and nullable types + +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Identifiable | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|--------------|-------------------|-----------------------|------------| +| Can be instantiated | No | Experimental | No | Forbidden | Permitted | [typearrays.schema.json](typearrays.schema.json) | + +# Type Arrays Properties + +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [null](#null) | `null` | Optional | No | Type Arrays (this schema) | +| [string-or-null](#string-or-null) | `string` | Optional | Yes | Type Arrays (this schema) | +| [string-or-number](#string-or-number) | multiple | Optional | No | Type Arrays (this schema) | +| [string-or-number-null](#string-or-number-null) | multiple | Optional | Yes | Type Arrays (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | + +## null + +This is just nothing + +`null` +* is optional +* type: `null` +* defined in this schema + +### null Type + + +`null` +This property can only have the value `null`. + + + + +## string-or-null + +Nullable string + +`string-or-null` +* is optional +* type: `string` +* defined in this schema + +### string-or-null Type + + +`string`, nullable + + + + + + +## string-or-number + +Types can be many things + +`string-or-number` +* is optional +* type: multiple +* defined in this schema + +### string-or-number Type + + +Either one of: + * `string` + * `number` + + + + + +## string-or-number-null + +Types can be many things, even nothing at all. + +`string-or-number-null` +* is optional +* type: multiple +* defined in this schema + +### string-or-number-null Type + + +Either one of: + * `string` + * `number` + * or `null` + + + + diff --git a/examples/generated-schemas/typearrays.schema.json b/examples/generated-schemas/typearrays.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..ca4fd9eeffcfd95ca906856687a4a2a33b3e0825 --- /dev/null +++ b/examples/generated-schemas/typearrays.schema.json @@ -0,0 +1,46 @@ +{ + "meta:license": [ + "Copyright 2017 Adobe Systems Incorporated. All rights reserved.", + "This file is licensed to you under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License. You may obtain a copy", + "of the License at http://www.apache.org/licenses/LICENSE-2.0" + ], + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "https://example.com/schemas/typearrays", + "title": "Type Arrays", + "description": "This schema test type arrays and nullable types", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/id" + } + ], + "properties": { + "null": { + "type": "null", + "description": "This is just nothing" + }, + "string-or-null": { + "type": [ + "string", + "null" + ], + "description": "Nullable string" + }, + "string-or-number": { + "type": [ + "string", + "number" + ], + "description": "Types can be many things" + }, + "string-or-number-null": { + "type": [ + "string", + "number", + "null" + ], + "description": "Types can be many things, even nothing at all." + } + } +} \ No newline at end of file diff --git a/examples/schemas/typearrays.schema.json b/examples/schemas/typearrays.schema.json new file mode 100644 index 0000000000000000000000000000000000000000..60438f0a87d539f26f605f55d6319535d34192ac --- /dev/null +++ b/examples/schemas/typearrays.schema.json @@ -0,0 +1,36 @@ +{ + "meta:license": [ + "Copyright 2017 Adobe Systems Incorporated. All rights reserved.", + "This file is licensed to you under the Apache License, Version 2.0 (the 'License');", + "you may not use this file except in compliance with the License. You may obtain a copy", + "of the License at http://www.apache.org/licenses/LICENSE-2.0" + ], + "$schema": "http://json-schema.org/draft-06/schema#", + "$id": "https://example.com/schemas/typearrays", + "title": "Type Arrays", + "description": "This schema test type arrays and nullable types", + "type": "object", + "allOf": [ + { + "$ref": "#/definitions/id" + } + ], + "properties": { + "null": { + "type": "null", + "description": "This is just nothing" + }, + "string-or-null": { + "type": ["string", "null"], + "description": "Nullable string" + }, + "string-or-number": { + "type": ["string", "number"], + "description": "Types can be many things" + }, + "string-or-number-null": { + "type": ["string", "number", "null"], + "description": "Types can be many things, even nothing at all." + } + } +} \ No newline at end of file diff --git a/lib/markdownWriter.js b/lib/markdownWriter.js index 018a5dcb35166016501e3967226897bb8e1f5fe5..1a2b5711e21a5209af4dda8c994869e5d22290b5 100644 --- a/lib/markdownWriter.js +++ b/lib/markdownWriter.js @@ -103,6 +103,8 @@ function simpletype(prop) { prop.simpletype = '`integer`'; } else if (type==='object') { prop.simpletype = '`object`'; + } else if (type==='null') { + prop.simpletype = '`null`'; } else if (type==='array') { if (prop.items!==undefined) { const innertype = simpletype(prop.items); @@ -115,6 +117,21 @@ function simpletype(prop) { } else { prop.simpletype = '`array`'; } + } else if (Array.isArray(type)) { + function nullfilter(str) { + return str!=='null'; + } + var filtered = type.filter(nullfilter); + if (type.length - 1 === filtered.length) { + prop.nullable = true; + } + if (filtered.length===1) { + prop.type = filtered[0]; + prop.simpletype = '`' + filtered[0] + '`'; + } else { + prop.type = filtered; + prop.simpletype = 'multiple'; + } } else { prop.simpletype = 'complex'; } diff --git a/spec/examples/README.md b/spec/examples/README.md index cbf8be85683526a0b9ddbc90a9d00def620cb003..f6545c105f0a04557bc1922d27e2fcfe747da6e6 100644 --- a/spec/examples/README.md +++ b/spec/examples/README.md @@ -22,6 +22,7 @@ * [Simple](./simple.schema.md) – `https://example.com/schemas/simple` (Unknown) * [Simple Types](./simpletypes.schema.md) – `https://example.com/schemas/simpletypes` (Unknown) * [Stabilizing](./stabilizing.schema.md) – `https://example.com/schemas/stabilizing` (Stabilizing) +* [Type Arrays](./typearrays.schema.md) – `https://example.com/schemas/typearrays` (Unknown) ## /subdir/ diff --git a/spec/examples/arrays.schema.md b/spec/examples/arrays.schema.md index 74c7371d70d4b971396de79f67f032f5856ca1ce..4ed3a03d32a8c19c96ba21b9a006583ebd68a5a2 100644 --- a/spec/examples/arrays.schema.md +++ b/spec/examples/arrays.schema.md @@ -17,17 +17,17 @@ This is an example schema with examples for multiple array types and their const # Arrays Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [boollist](#boollist) | `boolean[]` | Optional | Arrays (this schema) | -| [coordinatelist](#coordinatelist) | `number[][]` | Optional | Arrays (this schema) | -| [intlist](#intlist) | `integer[]` | Optional | Arrays (this schema) | -| [list](#list) | `string[]` | Optional | Arrays (this schema) | -| [listlist](#listlist) | `array[]` | Optional | Arrays (this schema) | -| [numlist](#numlist) | `number[]` | Optional | Arrays (this schema) | -| [objectlist](#objectlist) | `object[]` | Optional | Arrays (this schema) | -| [stringlistlist](#stringlistlist) | `string[][]` | Optional | Arrays (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [boollist](#boollist) | `boolean[]` | Optional | No | Arrays (this schema) | +| [coordinatelist](#coordinatelist) | `number[][]` | Optional | No | Arrays (this schema) | +| [intlist](#intlist) | `integer[]` | Optional | No | Arrays (this schema) | +| [list](#list) | `string[]` | Optional | No | Arrays (this schema) | +| [listlist](#listlist) | `array[]` | Optional | No | Arrays (this schema) | +| [numlist](#numlist) | `number[]` | Optional | No | Arrays (this schema) | +| [objectlist](#objectlist) | `object[]` | Optional | No | Arrays (this schema) | +| [stringlistlist](#stringlistlist) | `string[][]` | Optional | No | Arrays (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## boollist diff --git a/spec/examples/complex.schema.md b/spec/examples/complex.schema.md index c813c30a2b0237ed74f602ea640e171cff2bdac2..d1faebd13ee94e79c5ee0f2da7d297ed855460f3 100644 --- a/spec/examples/complex.schema.md +++ b/spec/examples/complex.schema.md @@ -23,17 +23,17 @@ This is an example schema that uses types defined in other schemas. # Complex References Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [and](#and) | complex | Optional | Complex References (this schema) | -| [or](#or) | complex | Optional | Complex References (this schema) | -| [refabstract](#refabstract) | `object` | **Required** | Complex References (this schema) | -| [reflist](#reflist) | Simple | Optional | Complex References (this schema) | -| [refnamed](#refnamed) | Simple | Optional | Complex References (this schema) | -| [xor](#xor) | complex | Optional | Complex References (this schema) | -| `int.*` | `integer` | Pattern | Complex References (this schema) | -| `str.*` | `string` | Pattern | Complex References (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [and](#and) | complex | Optional | No | Complex References (this schema) | +| [or](#or) | complex | Optional | No | Complex References (this schema) | +| [refabstract](#refabstract) | `object` | **Required** | No | Complex References (this schema) | +| [reflist](#reflist) | Simple | Optional | No | Complex References (this schema) | +| [refnamed](#refnamed) | Simple | Optional | No | Complex References (this schema) | +| [xor](#xor) | complex | Optional | No | Complex References (this schema) | +| `int.*` | `integer` | Pattern No | Complex References (this schema) | +| `str.*` | `string` | Pattern No | Complex References (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## and diff --git a/spec/examples/constants.schema.md b/spec/examples/constants.schema.md index cf4c3870e8783b26e91e350fb9c988f41215df13..fb265efec49405c34940c8bc3fc25fdf04e85aa6 100644 --- a/spec/examples/constants.schema.md +++ b/spec/examples/constants.schema.md @@ -17,10 +17,10 @@ This is an example schema with examples for properties with constant values # Constant Types Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [hello](#hello) | `const` | **Required** | Constant Types (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [hello](#hello) | `const` | **Required** | No | Constant Types (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## hello diff --git a/spec/examples/custom.schema.md b/spec/examples/custom.schema.md index d2971e16b2c3fd8449f0b75bc80eac5c4229d552..fda33c9f426a1be000f5c9c9b21c7d1ff2e0f9df 100644 --- a/spec/examples/custom.schema.md +++ b/spec/examples/custom.schema.md @@ -17,11 +17,11 @@ This is an extensible schema. It has `definitions`, that can be used in other sc # Custom Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [bar](#bar) | `string` | Optional | Custom (this schema) | -| [foo](#foo) | `string` | Optional | Custom (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [bar](#bar) | `string` | Optional | No | Custom (this schema) | +| [foo](#foo) | `string` | Optional | No | Custom (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## bar diff --git a/spec/examples/deepextending.schema.md b/spec/examples/deepextending.schema.md index 4ec03594460cfb8dfb90cb8bd45ee3848014cb05..b9f0a69c40d520e9f543c6171cfcec19956cd24f 100644 --- a/spec/examples/deepextending.schema.md +++ b/spec/examples/deepextending.schema.md @@ -24,15 +24,15 @@ This is an extending schema. It is extending another extending schema. It pulls # Deeply Extending Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [@id](#id) | `string` | Optional | [Definitions](definitions.schema.md#id) | -| [bar](#bar) | `string` | Optional | [Extensible](extensible.schema.md#bar) | -| [baz](#baz) | `string` | Optional | [Extending](extending.schema.md#baz) | -| [hey](#hey) | `string` | Optional | Deeply Extending (this schema) | -| [id](#id-1) | `string` | Optional | [Definitions](definitions.schema.md#id-1) | -| [meta:id](#metaid) | `string` | Optional | [Definitions](definitions.schema.md#metaid) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [@id](#id) | `string` | Optional | No | [Definitions](definitions.schema.md#id) | +| [bar](#bar) | `string` | Optional | No | [Extensible](extensible.schema.md#bar) | +| [baz](#baz) | `string` | Optional | No | [Extending](extending.schema.md#baz) | +| [hey](#hey) | `string` | Optional | No | Deeply Extending (this schema) | +| [id](#id-1) | `string` | Optional | No | [Definitions](definitions.schema.md#id-1) | +| [meta:id](#metaid) | `string` | Optional | No | [Definitions](definitions.schema.md#metaid) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## @id diff --git a/spec/examples/definitions.schema.md b/spec/examples/definitions.schema.md index 0054a2ea8b065dffdc76a0e18390be3a6b7b1b7c..325397f7c2a6bde2211add30bda6daa32bfcddd5 100644 --- a/spec/examples/definitions.schema.md +++ b/spec/examples/definitions.schema.md @@ -34,12 +34,12 @@ aks. # Definitions Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [@id](#id) | `string` | Optional | Definitions (this schema) | -| [id](#id-1) | `string` | **Required** | Definitions (this schema) | -| [meta:id](#metaid) | `string` | Optional | Definitions (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [@id](#id) | `string` | Optional | No | Definitions (this schema) | +| [id](#id-1) | `string` | **Required** | No | Definitions (this schema) | +| [meta:id](#metaid) | `string` | Optional | No | Definitions (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## @id diff --git a/spec/examples/enums.schema.md b/spec/examples/enums.schema.md index 93d471654eadb7897b966a61b9482d20f0aadde0..df130568c653206b8d678e4ad6f13efa53e87fd1 100644 --- a/spec/examples/enums.schema.md +++ b/spec/examples/enums.schema.md @@ -17,11 +17,11 @@ This is an example schema with examples for properties with enum values # Enumerated Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [hello](#hello) | `enum` | **Required** | Enumerated (this schema) | -| [nested](#nested) | `object` | Optional | Enumerated (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [hello](#hello) | `enum` | **Required** | No | Enumerated (this schema) | +| [nested](#nested) | `object` | Optional | No | Enumerated (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## hello diff --git a/spec/examples/example.schema.md b/spec/examples/example.schema.md index 39a7d67437492bdde4b4f4185e39440f20a2d0fd..a17b01d64459de577661749a722269a677402bb7 100644 --- a/spec/examples/example.schema.md +++ b/spec/examples/example.schema.md @@ -25,11 +25,11 @@ This is an example schema with examples. Too many examples? There can never be t # Example Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [bar](#bar) | `string` | Optional | Example (this schema) | -| [foo](#foo) | `string` | Optional | Example (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [bar](#bar) | `string` | Optional | No | Example (this schema) | +| [foo](#foo) | `string` | Optional | No | Example (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## bar diff --git a/spec/examples/examples.schema.md b/spec/examples/examples.schema.md index 5d4aa2ca7ebfed62be546e3be03db4211728114f..00b8de4811ae12fb12c1bfa30a29d3eac42709e4 100644 --- a/spec/examples/examples.schema.md +++ b/spec/examples/examples.schema.md @@ -34,11 +34,11 @@ This is an example schema with *multiple* examples. Too many examples? There can # Examples Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [bar](#bar) | `string` | **Required** | Examples (this schema) | -| [foo](#foo) | `string` | Optional | Examples (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [bar](#bar) | `string` | **Required** | No | Examples (this schema) | +| [foo](#foo) | `string` | Optional | No | Examples (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## bar diff --git a/spec/examples/extending.schema.md b/spec/examples/extending.schema.md index bc55d8728ab2bd21963f8cfe51e009bb500fb1d3..178084096524ae84b4a98fefa3aafa4118ba52fc 100644 --- a/spec/examples/extending.schema.md +++ b/spec/examples/extending.schema.md @@ -23,14 +23,14 @@ This is an extending schema. It pulls `definitions` from other schemas. # Extending Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [@id](#id) | `string` | Optional | [Definitions](definitions.schema.md#id) | -| [bar](#bar) | `string` | Optional | [Extensible](extensible.schema.md#bar) | -| [baz](#baz) | `string` | Optional | Extending (this schema) | -| [id](#id-1) | `string` | Optional | [Definitions](definitions.schema.md#id-1) | -| [meta:id](#metaid) | `string` | Optional | [Definitions](definitions.schema.md#metaid) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [@id](#id) | `string` | Optional | No | [Definitions](definitions.schema.md#id) | +| [bar](#bar) | `string` | Optional | No | [Extensible](extensible.schema.md#bar) | +| [baz](#baz) | `string` | Optional | No | Extending (this schema) | +| [id](#id-1) | `string` | Optional | No | [Definitions](definitions.schema.md#id-1) | +| [meta:id](#metaid) | `string` | Optional | No | [Definitions](definitions.schema.md#metaid) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## @id diff --git a/spec/examples/identifiable.schema.md b/spec/examples/identifiable.schema.md index d0dc69e4a00ffed1196ddf4ca847191b8427e317..a3060fc196b1dc9b45cd04aaf179af04b7a1487e 100644 --- a/spec/examples/identifiable.schema.md +++ b/spec/examples/identifiable.schema.md @@ -17,10 +17,10 @@ This is a *very* simple example of a JSON schema. There is only one property. # Identifiable Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [@id](#id) | `string` | Optional | Identifiable (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [@id](#id) | `string` | Optional | No | Identifiable (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## @id diff --git a/spec/examples/simple.schema.md b/spec/examples/simple.schema.md index b801c02f404115e1ccfe9d8e24186df46e6ce035..4d533638fc47c37b450d70d90c98199f110bcbe0 100644 --- a/spec/examples/simple.schema.md +++ b/spec/examples/simple.schema.md @@ -17,10 +17,10 @@ This is a *very* simple example of a JSON schema. There is only one property. # Simple Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [id](#id) | `string` | Optional | Simple (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [id](#id) | `string` | Optional | No | Simple (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## id diff --git a/spec/examples/simpletypes.schema.md b/spec/examples/simpletypes.schema.md index b030c5ad4cb58776086a4d92a35b764a00199f4e..109b8364b5f70aeed0a718c57842ca9e8ae4bd6c 100644 --- a/spec/examples/simpletypes.schema.md +++ b/spec/examples/simpletypes.schema.md @@ -17,26 +17,26 @@ This is an example schema with examples for multiple types and their constraints # Simple Types Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [integer_threes](#integer_threes) | `integer` | Optional | Simple Types (this schema) | -| [interger_constrained](#interger_constrained) | `integer` | Optional | Simple Types (this schema) | -| [interger_unconstrained](#interger_unconstrained) | `integer` | Optional | Simple Types (this schema) | -| [number_constrained](#number_constrained) | `number` | Optional | Simple Types (this schema) | -| [number_unconstrained](#number_unconstrained) | `number` | Optional | Simple Types (this schema) | -| [string_date](#string_date) | `string` | Optional | Simple Types (this schema) | -| [string_email](#string_email) | `string` | Optional | Simple Types (this schema) | -| [string_hostname](#string_hostname) | `string` | Optional | Simple Types (this schema) | -| [string_ipv4](#string_ipv4) | `string` | Optional | Simple Types (this schema) | -| [string_ipv6](#string_ipv6) | `string` | Optional | Simple Types (this schema) | -| [string_length](#string_length) | `string` | Optional | Simple Types (this schema) | -| [string_pattern](#string_pattern) | `string` | Optional | Simple Types (this schema) | -| [string_pattern_noexample](#string_pattern_noexample) | `string` | Optional | Simple Types (this schema) | -| [string_pattern_singleexample](#string_pattern_singleexample) | `string` | Optional | Simple Types (this schema) | -| [string_unconstrained](#string_unconstrained) | `string` | Optional | Simple Types (this schema) | -| [string_uri](#string_uri) | `string` | Optional | Simple Types (this schema) | -| [yesno](#yesno) | `boolean` | **Required** | Simple Types (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [integer_threes](#integer_threes) | `integer` | Optional | No | Simple Types (this schema) | +| [interger_constrained](#interger_constrained) | `integer` | Optional | No | Simple Types (this schema) | +| [interger_unconstrained](#interger_unconstrained) | `integer` | Optional | No | Simple Types (this schema) | +| [number_constrained](#number_constrained) | `number` | Optional | No | Simple Types (this schema) | +| [number_unconstrained](#number_unconstrained) | `number` | Optional | No | Simple Types (this schema) | +| [string_date](#string_date) | `string` | Optional | No | Simple Types (this schema) | +| [string_email](#string_email) | `string` | Optional | No | Simple Types (this schema) | +| [string_hostname](#string_hostname) | `string` | Optional | No | Simple Types (this schema) | +| [string_ipv4](#string_ipv4) | `string` | Optional | No | Simple Types (this schema) | +| [string_ipv6](#string_ipv6) | `string` | Optional | No | Simple Types (this schema) | +| [string_length](#string_length) | `string` | Optional | No | Simple Types (this schema) | +| [string_pattern](#string_pattern) | `string` | Optional | No | Simple Types (this schema) | +| [string_pattern_noexample](#string_pattern_noexample) | `string` | Optional | No | Simple Types (this schema) | +| [string_pattern_singleexample](#string_pattern_singleexample) | `string` | Optional | No | Simple Types (this schema) | +| [string_unconstrained](#string_unconstrained) | `string` | Optional | No | Simple Types (this schema) | +| [string_uri](#string_uri) | `string` | Optional | No | Simple Types (this schema) | +| [yesno](#yesno) | `boolean` | **Required** | No | Simple Types (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## integer_threes diff --git a/spec/examples/stabilizing.schema.md b/spec/examples/stabilizing.schema.md index cc1a08297d82e3ca6e383a8fcb6900b60d2f4403..c98a34674158239db36dfb963669d307604a0654 100644 --- a/spec/examples/stabilizing.schema.md +++ b/spec/examples/stabilizing.schema.md @@ -17,10 +17,10 @@ This is a schema which is currently in the `stabilizing` status. # Stabilizing Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [id](#id) | `string` | Optional | Stabilizing (this schema) | -| `*` | any | Additional | this schema *allows* additional properties | +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [id](#id) | `string` | Optional | No | Stabilizing (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | ## id diff --git a/spec/examples/typearrays.schema.md b/spec/examples/typearrays.schema.md new file mode 100644 index 0000000000000000000000000000000000000000..a31629bd04ee45532bccd497cdaff72d694ae381 --- /dev/null +++ b/spec/examples/typearrays.schema.md @@ -0,0 +1,104 @@ +--- +template: reference +foo: bar +--- + +# Type Arrays Schema + +``` +https://example.com/schemas/typearrays +``` + +This schema test type arrays and nullable types + +| [Abstract](../abstract.md) | Extensible | [Status](../status.md) | Identifiable | Custom Properties | Additional Properties | Defined In | +|----------------------------|------------|------------------------|--------------|-------------------|-----------------------|------------| +| Can be instantiated | No | Experimental | No | Forbidden | Permitted | [typearrays.schema.json](typearrays.schema.json) | + +# Type Arrays Properties + +| Property | Type | Required | Nullable | Defined by | +|----------|------|----------|----------|------------| +| [null](#null) | `null` | Optional | No | Type Arrays (this schema) | +| [string-or-null](#string-or-null) | `string` | Optional | Yes | Type Arrays (this schema) | +| [string-or-number](#string-or-number) | multiple | Optional | No | Type Arrays (this schema) | +| [string-or-number-null](#string-or-number-null) | multiple | Optional | Yes | Type Arrays (this schema) | +| `*` | any | Additional | Yes | this schema *allows* additional properties | + +## null + +This is just nothing + +`null` +* is optional +* type: `null` +* defined in this schema + +### null Type + + +`null` +This property can only have the value `null`. + + + + +## string-or-null + +Nullable string + +`string-or-null` +* is optional +* type: `string` +* defined in this schema + +### string-or-null Type + + +`string`, nullable + + + + + + +## string-or-number + +Types can be many things + +`string-or-number` +* is optional +* type: multiple +* defined in this schema + +### string-or-number Type + + +Either one of: + * `string` + * `number` + + + + + +## string-or-number-null + +Types can be many things, even nothing at all. + +`string-or-number-null` +* is optional +* type: multiple +* defined in this schema + +### string-or-number-null Type + + +Either one of: + * `string` + * `number` + * or `null` + + + + diff --git a/spec/lib/integrationTest.spec.js b/spec/lib/integrationTest.spec.js index ae86bfb2ee00bc9e606ac2c797fb6f820d2342f3..5107d18415a34f7bb4663a2093a3572013b90d0c 100644 --- a/spec/lib/integrationTest.spec.js +++ b/spec/lib/integrationTest.spec.js @@ -54,7 +54,7 @@ describe('Compare results', () => { ls.on('close', code => { expect(code).toEqual(0); const files = readdirSync('./spec/examples').filter(item => !(/(^|\/)\.[^\/\.]/g).test(item)); - expect(files.length).toEqual(18); + expect(files.length).toEqual(19); done(); }); }); diff --git a/templates/md/boolean-type.ejs b/templates/md/boolean-type.ejs index a5789ce859ed406358659a9fd8e6dd1e7a276808..85a9b07bbbff621b7cdfb635b287c15e56bbd65a 100644 --- a/templates/md/boolean-type.ejs +++ b/templates/md/boolean-type.ejs @@ -5,4 +5,4 @@ * of the License at http://www.apache.org/licenses/LICENSE-2.0 */ %> -`<%=schema.type %>` +`<%=schema.type %>`<%=schema.nullable ? ", nullable" : "" %> diff --git a/templates/md/multiple-type.ejs b/templates/md/multiple-type.ejs new file mode 100644 index 0000000000000000000000000000000000000000..57accdf192273e5b93c47641bf9cd5cedb8a52d1 --- /dev/null +++ b/templates/md/multiple-type.ejs @@ -0,0 +1,13 @@ +<% /** + * Copyright 2018 Adobe Systems Incorporated. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + */ %> + +Either one of: +<% _.forEach(schema.type, (t) => { %> + * `<%= t %>` +<% }); %><% if (schema.nullable) { %> + * or `null` +<% } %> \ No newline at end of file diff --git a/templates/md/null-type.ejs b/templates/md/null-type.ejs new file mode 100644 index 0000000000000000000000000000000000000000..f65aa1501e9101da04efcbbb7186c72d8a79dd4f --- /dev/null +++ b/templates/md/null-type.ejs @@ -0,0 +1,10 @@ +<% /** + * Copyright 2018 Adobe Systems Incorporated. All rights reserved. + * This file is licensed to you under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. You may obtain a copy + * of the License at http://www.apache.org/licenses/LICENSE-2.0 + */ %> + +`null` + +This property can only have the value `null`. \ No newline at end of file diff --git a/templates/md/number-type.ejs b/templates/md/number-type.ejs index 6f32d87c5de61558ca44b800b55f6b92038b9b7d..e5953bf5f19670c1a593ef658eff249ddc44ab55 100644 --- a/templates/md/number-type.ejs +++ b/templates/md/number-type.ejs @@ -5,7 +5,7 @@ * of the License at http://www.apache.org/licenses/LICENSE-2.0 */ %> -`<%=schema.type %>` +`<%=schema.type %>`<%=schema.nullable ? ", nullable" : "" %> <% if(schema.exclusiveMinumum!==undefined) { %>* value must not be smaller or equal than: `<%=schema.exclusiveMinumum %>`<% } else if(schema.minimum!==undefined) { diff --git a/templates/md/object-type.ejs b/templates/md/object-type.ejs index 12b7462b4aeb151e634a41ac393d67962c973a58..7b7994225a030df87fe8614299bff84ea93cc1fc 100644 --- a/templates/md/object-type.ejs +++ b/templates/md/object-type.ejs @@ -5,7 +5,7 @@ * of the License at http://www.apache.org/licenses/LICENSE-2.0 */ %> -`object` with following properties: +`object`<%=schema.nullable ? ", nullable," : "" %> with following properties: <%- include("nested-properties",{outer:schema,props: schema.properties,_:_, nested:true}) %> diff --git a/templates/md/properties.ejs b/templates/md/properties.ejs index 583301de782e410cd36208df2321149cd67a8028..238928fff8ba918a3dc1144d753688f2814d73f1 100644 --- a/templates/md/properties.ejs +++ b/templates/md/properties.ejs @@ -8,11 +8,11 @@ <% const hasDefault = _.keys(props).filter(property => _.has(props, property + '.default')).length > 0; %> -| Property | Type | Required |<% if(hasDefault) { %> Default |<% } %> Defined by | -|----------|------|----------|<% if(hasDefault) { %>---------|<% } %>------------| +| Property | Type | Required | Nullable |<% if(hasDefault) { %> Default |<% } %> Defined by | +|----------|------|----------|----------|<% if(hasDefault) { %>---------|<% } %>------------| <% _.keys(props).sort().forEach(property => { const schema = props[property]; %> -| [<%= property %>](#<%= propertiesSlugs[property] %>) | <%= schema.simpletype %> | <%= schema.isrequired === true ? "**Required**" : "Optional" %> |<% if(hasDefault) { %> <% if (schema.default!==undefined) { %>`<%- JSON.stringify(schema.default) %>`<% } %> |<% } %> <% +| [<%= property %>](#<%= propertiesSlugs[property] %>) | <%= schema.simpletype %> | <%= schema.isrequired === true ? "**Required**" : "Optional" %> | <%= schema.nullable === true ? "Yes" : "No" %> |<% if(hasDefault) { %> <% if (schema.default!==undefined) { %>`<%- JSON.stringify(schema.default) %>`<% } %> |<% } %> <% if (schema.$oSchema) { %>[<%= schema.$oSchema.$linkVal %>](<%= schema.$oSchema.$linkPath %>#<%= propertiesSlugs[property] %>)<% } else { @@ -21,7 +21,7 @@ }); %><% _.keys(pprops).forEach(property => { const schema = pprops[property]; %> -| `<%= property.replace(':', '') %>` | <%= schema.simpletype %> | Pattern |<% if(hasDefault) { %> <% if (schema.default!==undefined) { %>`<%- JSON.stringify(schema.default) %>`<% } %> |<% } %> <% +| `<%= property.replace(':', '') %>` | <%= schema.simpletype %> | Pattern <%= schema.nullable === true ? "Yes" : "No" %> |<% if(hasDefault) { %> <% if (schema.default!==undefined) { %>`<%- JSON.stringify(schema.default) %>`<% } %> |<% } %> <% if (schema.$oSchema) { %>[<%= schema.$oSchema.$linkVal %>](<%= schema.$oSchema.$linkPath %>#<%= property.replace(':', '').toLowerCase() %>)<% } else { @@ -29,5 +29,5 @@ <% }); %><% if (additional!==false||additional===undefined) { %> -| `*` | any | Additional | this schema *allows* additional properties | +| `*` | any | Additional | Yes | this schema *allows* additional properties | <% } %> \ No newline at end of file diff --git a/templates/md/property.ejs b/templates/md/property.ejs index 0c2b7332fa04b3765904f2b2d83986fbcb44e99e..17aef7c8aef86670a38d5f8ee2f0454c391a41dc 100644 --- a/templates/md/property.ejs +++ b/templates/md/property.ejs @@ -41,6 +41,8 @@ The value of this property **must** be equal to one of the [known values below]( <%- include("string-type",{schema:schema,_:_}) %> <% } else if (schema.type==="number"||schema.type==="integer") { %> <%- include("number-type",{schema:schema,_:_}) %> +<% } else if (schema.type==="null") { %> +<%- include("null-type",{schema:schema,_:_}) %> <% } else if (schema.type==="boolean") { %> <%- include("boolean-type",{schema:schema,_:_}) %> <% } else if (schema.type==="object") { %> @@ -51,6 +53,8 @@ The value of this property **must** be equal to one of the [known values below]( <%- include("referenced-type",{schema:schema,_:_}) %> <% } else if (schema.anyOf!==undefined || schema.allOf!==undefined || schema.oneOf!==undefined) { %> <%- include("join-type",{schema:schema,_:_,schemas:schema.anyOf || schema.allOf || schema.oneOf,ejs:ejs}) %> +<% } else if (schema.simpletype==="multiple") { %> +<%- include("multiple-type",{schema:schema,_:_}) %> <% } else { %> Unknown type `<%= schema.type %>`. diff --git a/templates/md/string-type.ejs b/templates/md/string-type.ejs index 72e686e9e2dfbe4ac6da69da1e20ace1af82b199..0713c9344db33ce72473c57bb1258f826b70115c 100644 --- a/templates/md/string-type.ejs +++ b/templates/md/string-type.ejs @@ -5,7 +5,7 @@ * of the License at http://www.apache.org/licenses/LICENSE-2.0 */ %> -`string` +`string`<%=schema.nullable ? ", nullable" : "" %> <% if (schema.format==="uri") { %>* format: `uri` – Uniformous Resource Identifier (according to [RFC3986](http://tools.ietf.org/html/rfc3986))<% } else if (schema.format==="date-time") { %>* format: `date-time` – date and time (according to [RFC 3339, section 5.6](http://tools.ietf.org/html/rfc3339))<% }