feat: support context-aware empty value preservation#173
Merged
erunion merged 3 commits intoMay 26, 2026
Conversation
darrenyong
approved these changes
May 26, 2026
Comment on lines
+24
to
+31
| function shouldPreserve(rule: PreservationRule | undefined, context: PreservationContext) { | ||
| if (typeof rule === 'boolean') { | ||
| return rule; | ||
| } | ||
|
|
||
| return rule?.[context] ?? false; | ||
| } | ||
|
|
There was a problem hiding this comment.
should we add an early return for a falsy value of rule just to make it a little more clear?
Suggested change
| function shouldPreserve(rule: PreservationRule | undefined, context: PreservationContext) { | |
| if (typeof rule === 'boolean') { | |
| return rule; | |
| } | |
| return rule?.[context] ?? false; | |
| } | |
| function shouldPreserve(rule: PreservationRule | undefined, context: PreservationContext) { | |
| if (!rule) return false; | |
| if (typeof rule === 'boolean') { | |
| return rule; | |
| } | |
| return rule?.[context]; | |
| } | |
erunion
approved these changes
May 26, 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.
🧰 Changes
API Explorer uses empty objects as placeholders for object-shaped array items while the form is being edited. Those placeholders are useful in the UI, but they should not be sent as real values in the request payload.
The first pass added a dedicated option for empty objects inside arrays, but that made the package API more specific than it needed to be. This keeps the existing
preserveEmptyObjectandpreserveEmptyArrayoptions, and lets them accept a context map forroot,objectProperty, andarrayItem. Existing boolean usage still works, while callers that need more control can choose exactly where empty values should be preserved.For API Explorer, this means we can preserve intentional empty object properties while still filtering empty object array-item placeholders out of the payload.
🧬 QA & Testing
Added coverage for context-aware empty object and empty array preservation, including the case where both option maps are used together.