Allow parent elements' defaults higher precedence over deeper defaults
Aperta il 29 mag 2026
Descrizione
Prerequisites
- I have searched the existing issues
- I understand that providing a SSCCE example is tremendously useful to the maintainers.
- I have read the documentation
- Ideally, I'm providing a sample JSFiddle, Codesandbox.io or preferably a shared playground link demonstrating the issue.
What theme are you using?
core
Version
6.6.1 (or whatever version the playground uses)
Current Behavior
When defining an object element that contains a property with a default value, that value takes precedence over a value defined in the parent's default parameter.
See this playground example for a demonstration. The field gets pre-populated with "undesired default".
Expected Behavior
As per the documentation "Merging of defaults within the schema", we expect "desired default" to have precedence over the default value defined in "nested value":
In the schema itself, defaults of parent elements are propagated into children. So when you have a schema which defines a deeply nested object as default, these defaults will be applied to children of the current node. This also merges objects defined at different levels together with the "deeper" not having precedence.
[emphasis mine]
If we omit the deeper default definition like in this playground example, we get "desired default" as expected.
Steps To Reproduce
- open first playground example link
- copy JSON schema
- open new plain playground
- paste JSON schema
- take a look at the value the "nested value" input field was populated with
Environment
The Playground.
Also reproduces on:
- Docker Image: node:22-alpine3.22
- OS: Alpine 3.22
- Node: v22.22.3
- npm: 10.9.8
Anything else?
The issue does not seem to be specific to the root element, nested objects suffer from the same unexpected precedence. (playground)
The precedence is not only wrong for primitives like "string" or "integer". Setting a default value for a child object that has its own default definition also gets ignored. (playground)
Thank you for taking a look at this!