Closed
Description
Seems like there was some change in how beneathPath
works in 2.0.3
The following worked in 2.0.2:
...
responseFields(
beneathPath("ongoing"),
fieldWithPath("[].id").description("Order ID").type(JsonFieldType.STRING),
fieldWithPath("[].parentId")
.optional()
.description("Optional parent order ID")
.type(JsonFieldType.STRING),
fieldWithPath("[].type")
.description("Order type: `CONCRETE` or `ABSTRACT`(parent order)")
.type(JsonFieldType.STRING),
...
where document was(test data no personal info)
{
"ongoing" : [ {
"id" : "993",
"type" : "CONCRETE",
"state" : "ORDER_NEW",
"pickupTime" : "2019-01-14T14:03",
"pickup" : "Hus 556 Östlunds Väg 774, Söderfred, MS 04555",
"destination" : "Lgh. 845 Åslunds Väg 987, Karlfred, NV 26616",
"names" : [ "Prof. Erik Nilsson", "Elisabet Nilsson" ],
"phones" : [ "073-333-0667", "076-383-6377" ]
} ],
"finished" : [ {
"id" : "956",
"type" : "CONCRETE",
"state" : "ORDER_COMPLETED",
"pickupTime" : "2019-01-14T14:03",
"pickup" : "Eriks Väg 783, Köfors, NV 34227",
"destination" : "Aspvägen 88, Hatorp, SD 97209",
"names" : [ "Erik Eriksson", "PhD. Göran Änglund" ],
"phones" : [ "070-345-5394", "076-173-8762" ]
} ]
}
But starting from 2.0.3 I get this error message:
org.springframework.restdocs.snippet.SnippetException: The following parts of the payload were not documented:
{
"id" : "993",
"type" : "CONCRETE",
"state" : "ORDER_NEW",
"pickupTime" : "2019-01-14T14:03",
"pickup" : "Hus 556 Östlunds Väg 774, Söderfred, MS 04555",
"destination" : "Lgh. 845 Åslunds Väg 987, Karlfred, NV 26616",
"names" : [ "Prof. Erik Nilsson", "Elisabet Nilsson" ],
"phones" : [ "073-333-0667", "076-383-6377" ]
}
Fields with the following paths were not found in the payload: [[].id, [].type, [].state, [].pickupTime, [].pickup]
at org.springframework.restdocs.payload.AbstractFieldsSnippet.validateFieldDocumentation(AbstractFieldsSnippet.java:228)