Description
Specification section
10.2. Keywords for Applying Subschemas in Place
These keywords apply subschemas to the same location in the instance as the parent schema is being applied. They allow combining or modifying the subschema results in various ways.
[10.2.*.*] [...] An instance validates successfully against this keyword if it validates successfully against [some subset of] schema[(s)] defined by this keyword's value.
What is unclear?
- It doesn't define which applicator schema(s) are applied to the parent as subschemas.
- It doesn't define which results are gathered
The spec says the applicator applies subschemas - but not all of the applicator's contained schemas are actually subschemas of the instance. Many of them are only candidate subschemas as in the oneOf
applicator, explicitly not subschemas as in the not
applicator, or conditional as in the if
/then
/else
.
The spec says the applicators allow combining or modifying "subschema" results, but each applicator only defines how it determines the boolean "validity". Most of the applicators don't state anything about how they combine any other results like annotations or evaluated properties. For example, should the annotations of a valid schema with in a not
applicator be gathered? What about an invalid one? How about the properties of every valid schema within a anyOf
applicator be considered by unevaluatedProperties
, like with annotations?
Proposal
Here, I use "results" to mean all annotations, "evaluated" items/properties per unevaluated*
and additional*
keywords, and possibly other results like validation errors.
The spec should clarify, either for each applicator individually or for all applicators globally:
- The applicator provides results from all subschemas - even if they are invalid.
- The applicator does not provides results from non-subschemas. It uses their results to determine it's own, not to pass through.
- All valid, evaluated, applicator schemas are subschemas.
- For example, a valid schema in a
not
applicator is a subschema and can contribute results, even though it causes the applicator to be invalid. - The
anyOf
docs already clarify that all schemas need to be evaluated when collecting full results, but it might need to be added if this should include "evaluated" items/properties, or annotations only
- For example, a valid schema in a
- Invalid or unevaluated applicator schemas might still be subschemas, depending on the applicator's defined logic.
- For example, a valid
else
schema following a validif
schema, is not evaluated and does not produce results. - For example, each
allOf
schema is required to a subschema, even if it it invalid, and must provide results.
- For example, a valid
This would help quite a bit for unevaluated*
keywords, which seem to struggle from how to determine evaluated properties, especially from subschemas, per #1604 .
Do you think this work might require an [Architectural Decision Record (ADR)]? (significant or noteworthy)
No