With the second case (using "anyOf") - the default value from all matching
schemas is used. In your example, both schemas would apply, so the
instance has multiple defaults.
So the essence of the problem is the same as using "allOf" (the equivalent
of "extends" in v3):
The issue here is this: If we explicitly defined *which* default should be
used when there's more than one, we would need to define some kind of
ordering on the applied schemas. That's a can of worms I don't want to
So on balance, I would rather that we left the behaviour of "default"
undefined in this case. Perhaps some wording clarifying this in the
specification, such as:
Since multiple schemas can describe an instance, instances may have
multiple conflicting default values. Which default value (if any) should
be used in this case is not defined.
The specification does not explicitly state what agents can or cannot do
with the default value. Given that, I don't think that we particularly
need to nail down what happens when there are multiple defaults.