You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/2020-12/meta-data/default.markdown
+87-63Lines changed: 87 additions & 63 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,97 +28,121 @@ related:
28
28
keyword: deprecated
29
29
---
30
30
31
-
The `default` keyword in JSON Schema is used to specify a default value for an instance. This value is not automatically used to fill in missing values during the validation process but can be used by tools such as documentation or form generators.
31
+
The `default` keyword declares a default instance value for a schema or any of
32
+
its subschemas, typically to support specialised tooling like documentation and
33
+
form generators. This keyword does not affect validation, but the evaluator
34
+
will collect its value as an annotation.
32
35
33
-
_**Note:** While it is recommended that the default value validate against its subschema, this requirement is not strictly enforced._
36
+
{{<common-pitfall>}}
37
+
38
+
The standard evaluation process will not automatically use these values to fill
39
+
in missing parts of the instance. Furthermore, the JSON Schema specification
40
+
does not provide any guidance on how this keyword should be used.
41
+
42
+
Consult the documentation of any JSON Schema tooling you rely on to check if
43
+
and how it makes use of this keyword.
44
+
45
+
{{</common-pitfall>}}
46
+
47
+
{{<best-practice>}}
48
+
49
+
Meta-schema validation will not check that the default values you declare are
50
+
actually valid against their respective schemas, as JSON Schema does not offer
51
+
a mechanism for meta-schemas to declare that instances validate against parts
52
+
of the same instance being evaluated. As a consequence, it is not rare for
53
+
schemas to declare invalid default values that go undetected for a long time.
0 commit comments