Repository navigation
fix(core): keep nested required object defaults in their parent - #1251
Merged
erunion merged 2 commits intoNov 12, 2026
Merged
Conversation
getJSONSchemaDefaults seeded an empty object for every required object property at the root of the payload, whatever its depth, and the walk to a nested destination fell back to a throwaway object. A required object below the root was sent as an extra top-level key, so an API with additionalProperties false rejected the request, and a default set below the first level was lost (issue 1200). The parent is now resolved first. Required objects are seeded inside it, defaults are written into it, and when the parent is not in the defaults (an optional parent) the value is left out instead of being written at the root. Fixes readmeio#1200
🦋 Changeset detectedLatest commit: 3405ddf The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
erunion
approved these changes
Nov 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1200.
getJSONSchemaDefaults seeded an empty object for every required object property at the root of the defaults, whatever its depth. The walk to a nested destination also fell back to a throwaway object, so a default set below the first level was lost. With the issue's schema the body went out as customer, reference and an extra top-level address, and an API with additionalProperties false rejected every such request.
The parent is now resolved first, from the parent pointer the function already reads. A required object is seeded inside its parent, a default is written into its parent, and when the parent is not in the defaults (it is optional, or sits inside an array) the value is left out instead of landing at the root.
Two new tests in getJSONSchemaDefaults.test.ts use the issue's order schema. One checks that customer.address is seeded inside customer and keeps a nested default, and the other that a required child of an optional parent adds nothing. Both fail on main (the first gets address at the root and loses the default) and pass with this change. All 85 core tests pass, and tsc, oxlint and oxfmt are clean on both files.