Resolve leftover `allOf` branches inside `retrieveSchema`
Author: x0kCreated Sep 16, 2026Updated Sep 16, 2026
Labelsneeds triage
When an allOf holds several if/then/else blocks or several contains blocks, the merge step can only lift one of each to the top level. The extras are left behind in a leftover allOf, so every caller has to deal with unmerged branches on its own.
Proposal: resolve the extra branches up front, using the current form data, before merging.
const { allOf, ...rest } = resolvedSchema;
const toMerge = [rest];
let hasCondition = rest.if !== undefined;
for (const schemaDef of allOf) {
if (typeof schemaDef !== 'boolean' && schemaDef.if !== undefined) {
if (hasCondition) {
const r = retrieveSchema(validator, schemaDef, rootSchema, rawFormData);
if (!deepEquals(r, { not: {} })) {
toMerge.push(r);
}
continue;
}
hasCondition = true;
}
toMerge.push(schemaDef);
}
resolvedSchema = mergeAllOf({ allOf: toMerge });The merged result may still carry an allOf of { contains } branches but other callers can safely ignore it.
Note: merging behaves more like intersecting schemas than concatenating them, so the edge cases of this approach need thoughtful investigation before it lands.
Source: rjsf-team/react-jsonschema-form