Optional subsections are not aware that they are optional.
See original GitHub issueHello, I want to document the following payload.
{
"list" : [ {
"necessary" : "first",
"optional" : {
"field" : "b"
}
}, {
"necessary" : "second"
} ]
}
list[].optional
field is literally an optional field.
And here is my documentation code.
responseFields(
subsectionWithPath("list[]").description("list"),
),
responseFields(
beneathPath("list[]").withSubsectionId("sub1"),
fieldWithPath("necessary").description("necessary"),
subsectionWithPath("optional").description("optional").optional(),
),
responseFields(
beneathPath("list[].optional").withSubsectionId("sub2"),
fieldWithPath("field").description("field").optional(),
)
And I got an exception.
list[].optional identifies multiple sections of the payload and they do not have a common structure. The following non-optional uncommon paths were found: [list[].optional]
I’m guessing it’s because the list[].optional
path doesn’t have a clue that it is optional
(because the fact that list[].optional
should be optional appears in the list[]
path).
So, is there any feature like beneathPath("path").optional()
?
I’m using spring-restdocs-mockmvc:2.0.6
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
sectioning - optional subsection numbering: 2.1 2.2A 2.2B 2.3 ...
For a document, I'm trying to refer the reader to either section 2.2A or 2.2B depending on what they are looking for. Is...
Read more >Java 8 DateTimeFormatter parsing optional sections
The problem is that your pattern is considering the entire string as the year. You can use .appendValue(ChronoField.YEAR, 4) to limit it to ......
Read more >Creating optional sections with the section macro
The section macro lets you create optional sections that you can enable/disable by clicking on a checkbox. The section can contain text, ...
Read more >Template anatomy - AWS CloudFormation
You can refer to resources in the Resources and Outputs sections of the template. Outputs (optional). Describes the values that are returned whenever...
Read more >G.600 - PHS Assignment Request Form
This form is optional. Use it only if you wish to communicate specific awarding component assignments or review preferences. There is no ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You were relying on a bug, unfortunately.
A wildcard selecting multiple keys in a map is very similar to an array in that we’re then dealing with multiple parts of the payload that need to have the same structure for them to be documented accurately. Differing structures were being missed in some cases and throwing unhelpful errors in others. The changes for #715 mean that differing structures should now always be identified and the error message should be more helpful.
Unfortunately, I don’t think the behaviour you were relying on can be reinstated without regressing that fix.
Thank you 😃
I will fix my code.