Skip to content

Missing required field goes unreported when its path shares a prefix with an absent optional field - #1057

Open
harrisleesh wants to merge 1 commit into
spring-projects:mainfrom
harrisleesh:gh-1054
Open

harrisleesh wants to merge 1 commit into
spring-projects:mainfrom
harrisleesh:gh-1054

Conversation

@harrisleesh

Copy link
Copy Markdown

Fixes gh-1054

JsonContentHandler.isNestedBeneathMissingOptionalField used a plain string prefix test, so a required field whose path merely shared a string prefix with an absent optional field's path (optional a + required ab, or optional a.b + required a.bc) was treated as nested beneath it, and findMissingFields() never reported it — the snippet was generated with the missing required field undetected. resolveFieldType was affected the same way.

The check now requires the descendant path to continue with a . or [ segment boundary after the ancestor path. Added regression tests that fail on main and pass with the fix; all payload tests and spring-restdocs-core checks pass.

…stor

isNestedBeneathMissingOptionalField used a plain string prefix test, so
a required field whose path merely shared a string prefix with an
absent optional field's path (for example optional 'a' and required
'ab') was treated as nested beneath it and its absence was never
reported.

Require the path to continue with a '.' or '[' segment boundary after
the ancestor path.

Fixes spring-projectsgh-1054

Signed-off-by: seonghun lee <harrisleesh@gmail.com>
@wilkinsona wilkinsona changed the title Consider segment boundaries when checking for a missing optional ancestor Missing required field goes unreported when its path shares a prefix with an absent optional field Sep 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing required field goes unreported when its path shares a prefix with an absent optional field

2 participants