Repository navigation
Consider empty array documented when a field beneath it is documented - #1064
Open
sharanggupta wants to merge 1 commit into
Open
sharanggupta wants to merge 1 commit into
sharanggupta wants to merge 1 commit into
Conversation
When a field beneath an array is documented, for example items[].k2[].name, removing it from the payload cascades upwards and removes any container that the removal leaves empty. An items[] entry whose k2 array is empty to begin with is never reached by this cascade as it has no name entry to remove. The empty array is left behind and the payload is reported as having undocumented content even though every field in it has been documented. When traversal reaches an empty collection through a non-leaf array segment, it now notifies the callback. The callbacks used for removal remove the empty collection as they would a matched leaf, so that it and any containers it leaves empty are removed. The callbacks used to determine a field's presence and to extract its values ignore the notification so their behavior is unchanged. Fixes spring-projectsgh-626 Signed-off-by: Sharang Gupta <sharang@sharanggupta.dev>
sharanggupta
force-pushed
the
gh-626-mixed-presence-field-documentation
branch
from
October 6, 2026 22:03
c083e03 to
aa2bde4
Compare
This branch has not been deployed
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 gh-626
When a field beneath an array is documented, for example
items[].k2[].name, removing it from the payload cascades upwards and removes any container that the removal leaves empty. Anitems[]entry whosek2array is empty to begin with is never reached by this cascade because it has nonameentry to remove, so the empty array is left behind and the payload is reported as having undocumented content ({"items":[{"k2":[]}]}) even though every field in it has been documented.This change makes
JsonFieldProcessornotify its callback when traversal reaches an empty collection through a non-leaf array segment. The removal callbacks remove the empty collection as they would a matched leaf, so it and any containers it leaves empty are removed. The callbacks that determine a field's presence (hasField) and extract values for type discovery (extract) ignore the notification, so their behaviour is unchanged.Scope is deliberately limited to empty arrays, as described in the issue. The analogous mixed-presence cases of a
nullor an empty object on the path are left as they are; happy to look at those too if you think they belong in the same change.Tests cover
removeandremoveSubsectionon sometimes-empty and always-empty arrays, the exact payload from the issue viaJsonContentHandler#getUndocumentedContent, and an end-to-endResponseFieldsSnippetrendering. Thespring-restdocs-coresuite (907 tests),checkFormatand checkstyle pass.