@@ -8,34 +8,46 @@ for all JSON types.
8
8
single: metadata
9
9
single: title
10
10
single: description
11
+ single: examples
11
12
12
13
.. _metadata :
13
14
14
15
Metadata
15
16
--------
16
17
17
- JSON Schema includes a few keywords, ``title ``, ``description `` and
18
- ``default ``, that aren't strictly used for validation, but are used to
19
- describe parts of a schema.
18
+ JSON Schema includes a few keywords, ``title ``, ``description ``, `` default `` and
19
+ ``examples `` that aren't strictly used for validation, but are used to describe
20
+ parts of a schema.
20
21
21
22
The ``title `` and ``description `` keywords must be strings. A "title"
22
23
will preferably be short, whereas a "description" will provide a more
23
24
lengthy explanation about the purpose of the data described by the
24
25
schema. Neither are required, but they are encouraged for good
25
- practice.
26
+ practice, and can make your schema "self-documenting" .
26
27
27
28
The ``default `` keyword specifies a default value for an item. JSON
28
29
processing tools may use this information to provide a default value
29
30
for a missing key/value pair, though many JSON schema validators
30
31
simply ignore the ``default `` keyword. It should validate against the
31
32
schema in which it resides, but that isn't required.
32
33
34
+ |draft6 | The ``examples `` keyword is a place to provide an array of examples
35
+ that validate against the schema. This isn't used for validation, but may help
36
+ with explaining the effect and purpose of the schema to a reader. Each entry
37
+ should validate against the schema in which is resides, but that isn't strictly
38
+ required. There is no need to duplicate the ``default `` value in the
39
+ ``examples `` array, since ``default `` will be treated as another example.
40
+
33
41
.. schema_example ::
34
42
35
43
{
36
44
"title" : "Match anything",
37
45
"description" : "This is a schema that matches anything.",
38
- "default" : "Default value"
46
+ "default" : "Default value",
47
+ "examples" : [
48
+ "Anything",
49
+ 4035
50
+ ]
39
51
}
40
52
41
53
.. index ::
0 commit comments