diff --git a/examples/docs/README.md b/examples/docs/README.md index c5afc3252bf6f8f87248071a46e2d0e77266b5f5..0502d30d53aa01bd12e680be8b6d8b1c1c658843 100644 --- a/examples/docs/README.md +++ b/examples/docs/README.md @@ -24,6 +24,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 18624428a451bacd5911492803f5772c55f7b3fe..99b043475eddc64edd55bdbc6456d6b234b0191e 100644 --- a/examples/docs/arrays.schema.md +++ b/examples/docs/arrays.schema.md @@ -17,18 +17,18 @@ This is an example schema with examples for multiple array types and their const # Arrays Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [JoinTypelist](#jointypelist) | `array` | Optional | Arrays (this schema) | -| [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 | +|----------|------|----------|----------|------------| +| [JoinTypelist](#jointypelist) | `array` | Optional | No | Arrays (this schema) | +| [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 | ## JoinTypelist diff --git a/examples/docs/complex.schema.md b/examples/docs/complex.schema.md index 680809525d9515597f9cce32a66c296be72c35a6..098be5c9429a29358371424b5f99872daa5efff9 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 03c8088286ea94d244804cf23398edad2f236d61..eaf3ddc94bdc28b92c80b9f7835c73fcf1e41906 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 00be849c53fbc025a6cf8ff49247f0b3a91da425..4e9aaaa3f40fe851dba429a6978d178fe40a27a1 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 20006a7c17f93febb2520e85d9856a64a59800d8..2a2faf13751c65cd118875e21b494b7ed925065e 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 638a92e62eb5c48d52a0a51979291b8fe58390b1..556bf882ae635731a96182d99eb9dc50216bef82 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 57d97014ac5c57e903e53a4a537c7fa4cda8d91a..8d3da8c79cddba359a79962c41014785c0de42eb 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 90979823352fc7ecbd2153b2edbaf4d8b9e07939..d6ea6ca1c8fa259fdc02dc2f29034650ff348352 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 c3ec772d10763a576196936519abc09b994660de..8de2b639931f8256294169f5c133cfaab00d5c66 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 b7239a79333d45ee4936f8581fc4ebfa7cd3cf3a..ebfb292b27045e4baa927c6e8049f3a012af2cf1 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 7a17ef652fccfe814030120db69457a43e5d21ab..d9e601107350b5163716009443b88863761ab4b0 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 c6da35228c5a1fc2fd2e7a9c17f2a904289d35e8..646f5b8f773821021769bf504cd67c864c016c38 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 fb4c47d4b07a493e9cb56f1ac7b89648c9753aa2..351cddc1876176733741ba64d22eda4258b3f4f0 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 71e4f7202797ada4b9b64d1e2e15342ec5fd8f3d..a1278169b481a1e27bbe58716e60d121acc28fe9 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..035564485daf178c9d4d28d6d9020e9136644fa0 --- /dev/null +++ b/examples/docs/typearrays.schema.md @@ -0,0 +1,119 @@ +--- +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` + + + + + + +**All** of the following *requirements* need to be fulfilled. + + +#### Requirement 1 + + +* []() – `#/definitions/id` + 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 5be91568cad715d2f5ce6eece5d65c31f9fdfd25..65ecc74846171789ade66be77f82f55c115a8d86 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 c5afc3252bf6f8f87248071a46e2d0e77266b5f5..0502d30d53aa01bd12e680be8b6d8b1c1c658843 100644 --- a/spec/examples/README.md +++ b/spec/examples/README.md @@ -24,6 +24,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 18624428a451bacd5911492803f5772c55f7b3fe..99b043475eddc64edd55bdbc6456d6b234b0191e 100644 --- a/spec/examples/arrays.schema.md +++ b/spec/examples/arrays.schema.md @@ -17,18 +17,18 @@ This is an example schema with examples for multiple array types and their const # Arrays Properties -| Property | Type | Required | Defined by | -|----------|------|----------|------------| -| [JoinTypelist](#jointypelist) | `array` | Optional | Arrays (this schema) | -| [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 | +|----------|------|----------|----------|------------| +| [JoinTypelist](#jointypelist) | `array` | Optional | No | Arrays (this schema) | +| [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 | ## JoinTypelist diff --git a/spec/examples/complex.schema.md b/spec/examples/complex.schema.md index 680809525d9515597f9cce32a66c296be72c35a6..098be5c9429a29358371424b5f99872daa5efff9 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 03c8088286ea94d244804cf23398edad2f236d61..eaf3ddc94bdc28b92c80b9f7835c73fcf1e41906 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 00be849c53fbc025a6cf8ff49247f0b3a91da425..4e9aaaa3f40fe851dba429a6978d178fe40a27a1 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 20006a7c17f93febb2520e85d9856a64a59800d8..2a2faf13751c65cd118875e21b494b7ed925065e 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 638a92e62eb5c48d52a0a51979291b8fe58390b1..556bf882ae635731a96182d99eb9dc50216bef82 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 57d97014ac5c57e903e53a4a537c7fa4cda8d91a..8d3da8c79cddba359a79962c41014785c0de42eb 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 90979823352fc7ecbd2153b2edbaf4d8b9e07939..d6ea6ca1c8fa259fdc02dc2f29034650ff348352 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 c3ec772d10763a576196936519abc09b994660de..8de2b639931f8256294169f5c133cfaab00d5c66 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 b7239a79333d45ee4936f8581fc4ebfa7cd3cf3a..ebfb292b27045e4baa927c6e8049f3a012af2cf1 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 7a17ef652fccfe814030120db69457a43e5d21ab..d9e601107350b5163716009443b88863761ab4b0 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 c6da35228c5a1fc2fd2e7a9c17f2a904289d35e8..646f5b8f773821021769bf504cd67c864c016c38 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 fb4c47d4b07a493e9cb56f1ac7b89648c9753aa2..351cddc1876176733741ba64d22eda4258b3f4f0 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 71e4f7202797ada4b9b64d1e2e15342ec5fd8f3d..a1278169b481a1e27bbe58716e60d121acc28fe9 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..035564485daf178c9d4d28d6d9020e9136644fa0 --- /dev/null +++ b/spec/examples/typearrays.schema.md @@ -0,0 +1,119 @@ +--- +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` + + + + + + +**All** of the following *requirements* need to be fulfilled. + + +#### Requirement 1 + + +* []() – `#/definitions/id` + diff --git a/spec/lib/integrationTest.spec.js b/spec/lib/integrationTest.spec.js index 6666fa3853e2cec8901713d51b840e61f4d1de46..061d7de439c157fd7c7a95ed1395551805498edc 100644 --- a/spec/lib/integrationTest.spec.js +++ b/spec/lib/integrationTest.spec.js @@ -1,5 +1,6 @@ const { spawn } = require('child_process'); -const { readFile, readdirSync, statSync } = require('fs'); +const path = require('path'); +const { readFileSync, readdirSync, statSync } = require('fs'); beforeEach(function() { jasmine.addMatchers( @@ -54,25 +55,17 @@ 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(20); - done(); - }); - }); + expect(files.length).toEqual(21); - const files = readdirSync('./spec/examples').filter(item => !(/(^|\/)\.[^\/\.]/g).test(item)); - files.forEach(file => { - if (statSync('./spec/examples/' + file).isFile()) { - it('Comparing ' + file, indone => { - console.log('file ' + file); - readFile('./spec/examples/' + file, (err, expectedbuf) => { - expect(err).toBeNull(); - readFile('./examples/docs/' + file, (err, actualbuf) => { - expect(err).toBeNull(); - expect(actualbuf.toString()).toEqual(expectedbuf.toString()); - indone(); - }); - }); + files.forEach(file => { + if (statSync('./spec/examples/' + file).isFile()) { + const expectedstr = readFileSync(path.resolve('./spec/examples/', file)).toString(); + const actualstr = readFileSync(path.resolve('./examples/docs/', file)).toString(); + expect(actualstr).toEqual(expectedstr, file + ' does not match'); + } }); - } + + 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 1fe14494e1a56bf555428c57fe3c4aac867e1191..dcc2d57a4174b1e933d3e1a80c81dea91ec19cad 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) { 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..73cdec164117bb1d1c8dfac5de0aab67d1850982 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 d1e803e99fce62c754481ab2f3e3125a3559a216..a85d416c9367429bd1426ae9043b4d8089ed0813 100644 --- a/templates/md/property.ejs +++ b/templates/md/property.ejs @@ -47,6 +47,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") { %> @@ -57,6 +59,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 84148f79bdc18991d3bd180cf42f03de8dd7b224..6edcbdfd5f90639c5fdb947ee289093f272635d3 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" : "" %> <%