Riddle
A schema says the retries property has a default of 3. The input instance is {}. Validation succeeds.
What should you expect the instance to contain afterward?
Answer
Still {}.
In JSON Schema, default describes a value associated with a particular schema. It does not, by itself, insert that value into the instance. Validation can accept a missing optional property without turning absence into 3.
That makes two separate questions easy to confuse. Is retries allowed to be absent? And if it is absent, should the application populate it? The schema can answer the validation question. Population is an application behavior that needs its own explicit step.
The JSON Schema Draft 2020-12 validation specification, published 16 June 2022, places default among the basic metadata annotations. It says the keyword supplies a default JSON value associated with a particular schema and recommends that the value be valid against that schema.
During evaluation, non-assertion information can be collected as annotation output at an instance location where a schema applies. That evaluation result still does not mutate the instance or create a missing property.
Q&A
Does required make the default appear?
No. Marking retries as required makes {} fail validation; it still does not populate the property.
Can a library offer default-filling anyway?
A library or wrapper can add that application behavior, but it should be treated as an explicit population feature rather than assumed from the schema keyword. Its timing matters too: populate first and validate the resulting instance if downstream code depends on the populated value.
What is the small implementation trap?
Do not use truthiness as a substitute for absence. An expression such as value || 3 replaces legitimate values including 0 and false. Check whether the property is actually absent, then apply 3, then validate the result.
Where, in your application, is the explicit population step that turns a missing retries property into 3 before the next validation pass?