My JSON response payload looks like this:
{
"count": 2,
"items": [
{
"k1": "v1",
"k2": []
},
{
"k1": "v2",
"k2": [
{
"name": "joe"
},
{
"name": "alice"
}
]
}
]
}
When I wrote Restdocs as bellow, I got an error complaining that items[].k2 = [] is not documented.
responseFields(
fieldWithPath("count").description("..."),
fieldWithPath("items[].k1").description("..."),
fieldWithPath("items[].k2[].name").description("...")
)
I tried to write fieldWithPath("items[].k2[].name").description("...").optional(), but it didn't do anything.