diff --git a/examples/docs/arrays.schema.md b/examples/docs/arrays.schema.md index f7dd628919a3ad116a06b9edbac3e464639408a1..8b8c786da93349a8ec6a02f2b4e7d1687e2bdc88 100644 --- a/examples/docs/arrays.schema.md +++ b/examples/docs/arrays.schema.md @@ -25,6 +25,7 @@ This is an example schema with examples for multiple array types and their const | [intlist](#intlist) | `integer[]` | Optional | Arrays (this schema) | | [boollist](#boollist) | `boolean[]` | Optional | Arrays (this schema) | | [numlist](#numlist) | `number[]` | Optional | Arrays (this schema) | +| [coordinatelist](#coordinatelist) | `number[][]` | Optional | Arrays (this schema) | ## list @@ -51,6 +52,7 @@ All items must be of the type: + ## listlist This is an array of arrays @@ -64,9 +66,9 @@ This is an array of arrays ### listlist Type -Array type: `array[]` +Nested array type: `array` + -All items must be of the type: Array type: `array` @@ -75,6 +77,8 @@ Array type: `array` + + ## stringlistlist This is an array of arrays of strings @@ -88,9 +92,9 @@ This is an array of arrays of strings ### stringlistlist Type -Array type: `string[][]` +Nested array type: `string[]` + -All items must be of the type: Array type: `string[]` All items must be of the type: @@ -105,6 +109,8 @@ All items must be of the type: + + ## intlist This is an array @@ -130,6 +136,7 @@ All items must be of the type: + ## boollist This is an array @@ -153,6 +160,7 @@ All items must be of the type: + ## numlist This is an array @@ -177,3 +185,40 @@ All items must be of the type: + + +## coordinatelist + +This is an array of coordinates in three-dimensional space. + +`coordinatelist` +* is optional +* type: `number[][]` (nested array) +* no more than `10` items in the array +* defined in this schema + +### coordinatelist Type + + +Nested array type: `number[]` + + +Array type: `number[]` + +All items must be of the type: +`number` +* minimum value: `0` +* maximum value: `10` + + + + + + +A coordinate, specified by `x`, `y`, and `z` values + + + + + + diff --git a/examples/docs/examples.schema.md b/examples/docs/examples.schema.md index 96c26345f5b50459173c53a60cddaba1a765dd68..57f409e244323ff47a5aa7ab6068cb422a537ad5 100644 --- a/examples/docs/examples.schema.md +++ b/examples/docs/examples.schema.md @@ -19,15 +19,15 @@ This is an example schema with *multiple* examples. Too many examples? There can ```json { - "foo": "zip", - "bar": "zap" + "foo": "bi", + "bar": "bu" } ``` ```json { - "foo": "bi", - "bar": "bu" + "foo": "zip", + "bar": "zap" } ``` diff --git a/examples/generated-schemas/arrays.schema.json b/examples/generated-schemas/arrays.schema.json index a6707af609452a1f49d3d2c8471c887a3130fe89..607a21b4d2fb56518962630f32b77030a397804d 100644 --- a/examples/generated-schemas/arrays.schema.json +++ b/examples/generated-schemas/arrays.schema.json @@ -60,6 +60,22 @@ "minimum": 10 }, "maxItems": 10 + }, + "coordinatelist": { + "type": "array", + "description": "This is an array of coordinates in three-dimensional space.", + "items": { + "type": "array", + "minItems": 3, + "maxItems": 3, + "description": "A coordinate, specified by `x`, `y`, and `z` values", + "items": { + "type": "number", + "minimum": 0, + "maximum": 10 + } + }, + "maxItems": 10 } } } \ No newline at end of file diff --git a/examples/generated-schemas/examples.schema.json b/examples/generated-schemas/examples.schema.json index 2a96fb91e33a8f032bf79aaff87530330c870af8..d46f1b75faa238b6976eb724d9dac9893a37c599 100644 --- a/examples/generated-schemas/examples.schema.json +++ b/examples/generated-schemas/examples.schema.json @@ -31,13 +31,13 @@ "bar" ], "examples": [ - { - "foo": "zip", - "bar": "zap" - }, { "foo": "bi", "bar": "bu" + }, + { + "foo": "zip", + "bar": "zap" } ] } \ No newline at end of file diff --git a/templates/md/array-type.ejs b/templates/md/array-type.ejs index 76f74d7c6ad916c4698a2d6cda3ec6008277166c..0799bddc7a933fc33c559f0738ceb30b4a73cb2a 100644 --- a/templates/md/array-type.ejs +++ b/templates/md/array-type.ejs @@ -4,11 +4,14 @@ * 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 */ %> - +<% if (schema.items!==undefined&&schema.items.type==="array") { %> +Nested array type: <%=schema.items.simpletype %> +<% } else { %> Array type: <%=schema.simpletype %> +<% } %> <% if (schema.items!==undefined) { %> - -All items must be of the type:<% +<% if (!(schema.items!==undefined&&schema.items.type==="array")) { %> +All items must be of the type:<% } if (schema.items.type==="string") { %><%- include("string-type",{schema:schema.items,_:_}) %><% } else if (schema.items.type==="number"||schema.items.type==="integer") { @@ -27,4 +30,10 @@ Unknown type `<%= schema.type %>`. <% } %> +<% if (schema.items.description!==undefined) { %> + +<%=schema.items.description %> + +<% } %> + <% } %>