From 6e1c6598570bcdf7b0b792f3ade6cac98a2b6e6e Mon Sep 17 00:00:00 2001
From: Lars Trieloff <trieloff@adobe.com>
Date: Wed, 13 Dec 2017 15:39:12 +0000
Subject: [PATCH] [trivial] provide an example of embedded examples

---
 examples/docs/README.md                       |  1 +
 examples/docs/definitions.schema.md           | 10 ++---
 examples/docs/example.schema.md               | 37 +++++++++++++++++++
 .../generated-schemas/definitions.schema.json |  7 +++-
 .../generated-schemas/example.schema.json     | 34 +++++++++++++++++
 examples/generated-schemas/simple.schema.json | 25 +++++++++++++
 .../subdir/subdir.schema.json                 | 29 +++++++++++++++
 examples/schemas/definitions.schema.json      |  7 +++-
 examples/schemas/example.example.1.json       |  4 ++
 examples/schemas/example.schema.json          | 25 +++++++++++++
 10 files changed, 170 insertions(+), 9 deletions(-)
 create mode 100644 examples/docs/example.schema.md
 create mode 100644 examples/generated-schemas/example.schema.json
 create mode 100644 examples/generated-schemas/simple.schema.json
 create mode 100644 examples/generated-schemas/subdir/subdir.schema.json
 create mode 100644 examples/schemas/example.example.1.json
 create mode 100644 examples/schemas/example.schema.json

diff --git a/examples/docs/README.md b/examples/docs/README.md
index 8ca78ab..8b904f2 100644
--- a/examples/docs/README.md
+++ b/examples/docs/README.md
@@ -7,6 +7,7 @@
 ## /
 
 * [Definitions](./definitions.schema.md) – `https://example.com/schemas/definitions`
+* [Example](./example.schema.md) – `https://example.com/schemas/example`
 * [Simple](./simple.schema.md) – `https://example.com/schemas/simple`
 
 ## /subdir/
diff --git a/examples/docs/definitions.schema.md b/examples/docs/definitions.schema.md
index 5e14172..90efcdd 100644
--- a/examples/docs/definitions.schema.md
+++ b/examples/docs/definitions.schema.md
@@ -13,15 +13,15 @@ It is imported using `allOf` and `$ref`.
 
 
 
+## Properties
 
 
-
-##  content
-### Properties
-
-###  id  
+###  id    
+* **Required**  
 *  **Type:** string  
 *  **Format:** uri
   
  A unique identifier given to every addressable thing.
 
+
+
diff --git a/examples/docs/example.schema.md b/examples/docs/example.schema.md
new file mode 100644
index 0000000..5f34cae
--- /dev/null
+++ b/examples/docs/example.schema.md
@@ -0,0 +1,37 @@
+
+
+
+  
+# Example
+
+  
+*  **Type:** object
+  
+This is an example schema with examples. Too many examples? There can never be too many examples!
+  
+**Examples:**
+```json
+{
+    "foo": "bar",
+    "bar": "baz"
+}
+```
+
+
+
+
+## Properties
+
+
+###  foo  
+*  **Type:** string
+  
+ A simple string.
+
+###  bar  
+*  **Type:** string
+  
+ A simple string.
+
+
+
diff --git a/examples/generated-schemas/definitions.schema.json b/examples/generated-schemas/definitions.schema.json
index aed499a..e916a3a 100644
--- a/examples/generated-schemas/definitions.schema.json
+++ b/examples/generated-schemas/definitions.schema.json
@@ -10,7 +10,7 @@
     "title": "Definitions",
     "type": "object",
     "definitions": {
-        "content": {
+        "myid": {
             "properties": {
                 "id": {
                     "type": "string",
@@ -22,8 +22,11 @@
     },
     "allOf": [
         {
-            "$ref": "#/definitions/id"
+            "$ref": "#/definitions/myid"
         }
     ],
+    "required": [
+        "id"
+    ],
     "description": "This is an example of using a `definitions` object within a schema.\n\nIt is imported using `allOf` and `$ref`."
 }
\ No newline at end of file
diff --git a/examples/generated-schemas/example.schema.json b/examples/generated-schemas/example.schema.json
new file mode 100644
index 0000000..2009591
--- /dev/null
+++ b/examples/generated-schemas/example.schema.json
@@ -0,0 +1,34 @@
+{
+    "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/example",
+    "title": "Example",
+    "type": "object",
+    "description": "This is an example schema with examples. Too many examples? There can never be too many examples!",
+    "properties": {
+        "foo": {
+            "type": "string",
+            "description": "A simple string.",
+            "meta:example": "bar"
+        },
+        "bar": {
+            "type": "string",
+            "description": "A simple string.",
+            "meta:example": [
+                "bar",
+                "baz"
+            ]
+        }
+    },
+    "examples": [
+        {
+            "foo": "bar",
+            "bar": "baz"
+        }
+    ]
+}
\ No newline at end of file
diff --git a/examples/generated-schemas/simple.schema.json b/examples/generated-schemas/simple.schema.json
new file mode 100644
index 0000000..e49f5d6
--- /dev/null
+++ b/examples/generated-schemas/simple.schema.json
@@ -0,0 +1,25 @@
+{
+    "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/simple",
+    "title": "Simple",
+    "description": "This is a *very* simple example of a JSON schema. There is only one property.",
+    "type": "object",
+    "allOf": [
+        {
+            "$ref": "#/definitions/id"
+        }
+    ],
+    "properties": {
+        "id": {
+            "type": "string",
+            "format": "uri",
+            "description": "A unique identifier given to every addressable thing."
+        }
+    }
+}
\ No newline at end of file
diff --git a/examples/generated-schemas/subdir/subdir.schema.json b/examples/generated-schemas/subdir/subdir.schema.json
new file mode 100644
index 0000000..c2009a2
--- /dev/null
+++ b/examples/generated-schemas/subdir/subdir.schema.json
@@ -0,0 +1,29 @@
+{
+    "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/subdir/subdir",
+    "title": "Subdir",
+    "type": "object",
+    "description": "A schema in a sub directory",
+    "definitions": {
+        "content": {
+            "properties": {
+                "id": {
+                    "type": "string",
+                    "format": "uri",
+                    "description": "A unique identifier given to every addressable thing."
+                }
+            }
+        }
+    },
+    "allOf": [
+        {
+            "$ref": "#/definitions/id"
+        }
+    ]
+}
\ No newline at end of file
diff --git a/examples/schemas/definitions.schema.json b/examples/schemas/definitions.schema.json
index bb72811..64e3fa9 100644
--- a/examples/schemas/definitions.schema.json
+++ b/examples/schemas/definitions.schema.json
@@ -10,7 +10,7 @@
   "title": "Definitions",
   "type": "object",
   "definitions": {
-    "content": {
+    "myid": {
       "properties": {
         "id": {
           "type": "string",
@@ -21,6 +21,9 @@
     }
   },
   "allOf": [
-    {"$ref": "#/definitions/id"}
+    {"$ref": "#/definitions/myid"}
+  ],
+  "required": [
+    "id"
   ]
 }
diff --git a/examples/schemas/example.example.1.json b/examples/schemas/example.example.1.json
new file mode 100644
index 0000000..7cdaab9
--- /dev/null
+++ b/examples/schemas/example.example.1.json
@@ -0,0 +1,4 @@
+{
+  "foo": "bar",
+  "bar": "baz"
+}
\ No newline at end of file
diff --git a/examples/schemas/example.schema.json b/examples/schemas/example.schema.json
new file mode 100644
index 0000000..af47ed2
--- /dev/null
+++ b/examples/schemas/example.schema.json
@@ -0,0 +1,25 @@
+{
+  "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/example",
+  "title": "Example",
+  "type": "object",
+  "description": "This is an example schema with examples. Too many examples? There can never be too many examples!",
+  "properties": {
+    "foo": {
+      "type": "string",
+      "description": "A simple string.",
+      "meta:example": "bar"
+    },
+    "bar": {
+      "type": "string",
+      "description": "A simple string.",
+      "meta:example": ["bar", "baz"]
+    }
+  }
+}
-- 
GitLab