From c9d1a6c75d9b177b4a0a1639f8bc4632e992ecb2 Mon Sep 17 00:00:00 2001
From: Lars Trieloff <trieloff@adobe.com>
Date: Thu, 14 Dec 2017 15:03:38 +0000
Subject: [PATCH] #14 array length restrictions

---
 examples/docs/arrays.schema.md                | 68 +++++++++++++++++++
 examples/generated-schemas/arrays.schema.json | 20 +++++-
 examples/schemas/arrays.schema.json           | 16 +++++
 templates/md/property.ejs                     |  6 +-
 4 files changed, 106 insertions(+), 4 deletions(-)

diff --git a/examples/docs/arrays.schema.md b/examples/docs/arrays.schema.md
index 5d5186e..bee5040 100644
--- a/examples/docs/arrays.schema.md
+++ b/examples/docs/arrays.schema.md
@@ -21,6 +21,8 @@ This is an example schema with examples for multiple array types and their const
 |----------|------|----------|------------|
 | [list](#list) | `string[]` | Optional | Arrays (this schema) |
 | [intlist](#intlist) | `integer[]` | Optional | Arrays (this schema) |
+| [boollist](#boollist) | `boolean[]` | Optional | Arrays (this schema) |
+| [numlist](#numlist) | `number[]` | Optional | Arrays (this schema) |
 
 ## list
 
@@ -29,6 +31,7 @@ This is an array
 `list`
 * is optional
 * type: `string[]`
+
 * defined in this schema
 
 ### list Type
@@ -58,6 +61,7 @@ This is an array
 `intlist`
 * is optional
 * type: `integer[]`
+* between `1` and `10` items in the array
 * defined in this schema
 
 ### intlist Type
@@ -72,6 +76,8 @@ Unknown type `array`.
     "type": "integer",
     "simpletype": "`integer`"
   },
+  "maxItems": 10,
+  "minItems": 1,
   "simpletype": "`integer[]`"
 }
 ```
@@ -79,3 +85,65 @@ Unknown type `array`.
 
 
 
+
+## boollist
+
+This is an array
+
+`boollist`
+* is optional
+* type: `boolean[]`
+* at least `1` items in the array
+* defined in this schema
+
+### boollist Type
+
+Unknown type `array`.
+
+```json
+{
+  "type": "array",
+  "description": "This is an array",
+  "items": {
+    "type": "boolean",
+    "simpletype": "`boolean`"
+  },
+  "minItems": 1,
+  "simpletype": "`boolean[]`"
+}
+```
+
+
+
+
+
+## numlist
+
+This is an array
+
+`numlist`
+* is optional
+* type: `number[]`
+* no more than `10` items in the array
+* defined in this schema
+
+### numlist Type
+
+Unknown type `array`.
+
+```json
+{
+  "type": "array",
+  "description": "This is an array",
+  "items": {
+    "type": "number",
+    "simpletype": "`number`"
+  },
+  "maxItems": 10,
+  "simpletype": "`number[]`"
+}
+```
+
+
+
+
diff --git a/examples/generated-schemas/arrays.schema.json b/examples/generated-schemas/arrays.schema.json
index 44df550..f11dc1d 100644
--- a/examples/generated-schemas/arrays.schema.json
+++ b/examples/generated-schemas/arrays.schema.json
@@ -23,7 +23,25 @@
             "description": "This is an array",
             "items": {
                 "type": "integer"
-            }
+            },
+            "maxItems": 10,
+            "minItems": 1
+        },
+        "boollist": {
+            "type": "array",
+            "description": "This is an array",
+            "items": {
+                "type": "boolean"
+            },
+            "minItems": 1
+        },
+        "numlist": {
+            "type": "array",
+            "description": "This is an array",
+            "items": {
+                "type": "number"
+            },
+            "maxItems": 10
         }
     }
 }
\ No newline at end of file
diff --git a/examples/schemas/arrays.schema.json b/examples/schemas/arrays.schema.json
index f70e6a1..134cba4 100644
--- a/examples/schemas/arrays.schema.json
+++ b/examples/schemas/arrays.schema.json
@@ -26,6 +26,22 @@
       },
       "maxItems": 10,
       "minItems": 1
+    },
+    "boollist": {
+      "type":"array",
+      "description": "This is an array",
+      "items": {
+        "type": "boolean"
+      },
+      "minItems": 1
+    },
+    "numlist": {
+      "type":"array",
+      "description": "This is an array",
+      "items": {
+        "type": "number"
+      },
+      "maxItems": 10
     }
   }
 }
diff --git a/templates/md/property.ejs b/templates/md/property.ejs
index 641c092..09f328b 100644
--- a/templates/md/property.ejs
+++ b/templates/md/property.ejs
@@ -15,9 +15,9 @@
 `<%=name %>`
 * is <% if (required) { %>**required**<% } else { %>optional<% } %>
 * type: <%=schema.simpletype %><% if (schema.type==='array') { %>
-<%   if (schema.maxItems!==undefined&&schema.minItems!==undefined) { %>* between `x` and `y` items in the array<% } 
-else if (schema.maxItems!==undefined                             ) { %>* no more than `y` items in the array<% }
-else if (schema.minItems!==undefined                             ) { %>* at least `x` items in the array<% } %>
+<%   if (schema.maxItems!==undefined&&schema.minItems!==undefined) { %>* between `<%=schema.minItems %>` and `<%=schema.maxItems %>` items in the array<% } 
+else if (schema.maxItems!==undefined                             ) { %>* no more than `<%=schema.maxItems %>` items in the array<% }
+else if (schema.minItems!==undefined                             ) { %>* at least `<%=schema.minItems %>` items in the array<% } %>
 <% } %>
 * defined in <% if (schema.$oSchema) { %>[<%= schema.$oSchema.$linkVal %>](<%= schema.$oSchema.$linkPath %>#<%= name %>)<% } else { %>this schema<% } %>
 
-- 
GitLab