Warn from SchemaField, for every type, when a non-empty anyOf hides a titled oneOf

Author: heath-freenomeCreated Oct 1, 2026Updated Oct 1, 2026
Labelscoreneeds triagefeatureany-one-all-of

Prerequisites

What theme are you using?

core

Is your feature request related to a problem? Please describe.

Follow-up from #5364 (#5319), found in a review of 7f9c730ed.

getXxxOfKey() picks the one keyword whose options are rendered, and a non-empty anyOf wins over the oneOf. Every reader of the options goes through it (SchemaField's getSelectSchemaInfo(), optionsList(), sanitizing, defaults, the layout grid), so a oneOf beside a non-empty anyOf is never rendered, whatever the field's type. Its titles are dropped without a warning:

json
{
  "type": "boolean",
  "anyOf": [{ "type": "boolean" }],
  "oneOf": [{ "const": true, "title": "On" }, { "const": false, "title": "Off" }]
}

With { "ui:widget": "select" }, the select is built from the anyOf, so "On"/"Off" never appear, and nothing is logged. The same holds for a string or number field, and for an object whose oneOf would render an option selector.

#5364 warns about this only in BooleanField, and only when the schema also has an enum (the altKey === ANY_OF_KEY branch of its non-constant warning). Without an enum, or for any other type, it's silent.

Describe the solution you'd like

Warn once from SchemaField, which already calls getXxxOfKey() for every field:

  1. In SchemaFieldRender, after getSelectSchemaInfo(), logOnce() a warning naming the field (fieldLabelForLog()) when:

    • the keyword picked is anyOf,
    • schema.oneOf is a non-empty array, and
    • hasOptionLabels(schema.oneOf, ONE_OF_KEY, uiSchema) is true, i.e. some oneOf option has a title or a ui:title in uiSchema.oneOf.

    The message says the oneOf isn't rendered because the anyOf is read first, and suggests moving the labels to the anyOf or merging the two lists.

  2. Skip it when a ui:field replaces the field, since a custom field may read the oneOf itself (the same custom-field caveat as #5398).

  3. Remove the altKey === ANY_OF_KEY branch from BooleanField, so the boolean enum case logs one warning, not two.

Tests:

  • SchemaField warns exactly once for a boolean without an enum (the schema above), a string, a number, and an object option selector.
  • It doesn't warn when the anyOf is empty (the oneOf is then rendered), when the oneOf has no titles, when there's only a oneOf, or when a ui:field is set.
  • BooleanField's existing enum + anyOf + titled oneOf test expects the SchemaField warning, still exactly once.

Reword the #5319 core entry in CHANGELOG-v7.md to say the warning covers any field.

This sits alongside #5398, which moves BooleanField's other two warnings into SchemaField; the two could land together.

Describe alternatives you've considered

  • Warn whenever a non-empty oneOf is hidden, titled or not. That also flags a oneOf written only for validation beside an anyOf, where nothing the author meant to show is lost.
  • Render both keywords, as separate selectors. That changes the long-standing anyOf-first precedence that every reader of the options relies on.
  • Leave the warning boolean-and-enum-only, as #5364 does.

Generated with Claude Code

Source: rjsf-team/react-jsonschema-form