@@ -17,6 +17,7 @@ import org.springframework.restdocs.hypermedia.HypermediaDocumentation.links
17
17
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document
18
18
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post
19
19
import org.springframework.restdocs.operation.preprocess.OperationRequestPreprocessor
20
+ import org.springframework.restdocs.payload.PayloadDocumentation.beneathPath
20
21
import org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath
21
22
import org.springframework.restdocs.payload.PayloadDocumentation.requestFields
22
23
import org.springframework.restdocs.payload.PayloadDocumentation.responseFields
@@ -51,6 +52,15 @@ class MockMvcRestDocumentationWrapperIntegrationTest(@Autowired private val mock
51
52
thenSnippetFileExists()
52
53
}
53
54
55
+ @Test
56
+ fun should_document_both_restdocs_and_resource_with_path () {
57
+ givenEndpointInvoked()
58
+
59
+ whenDocumentedWithPayloadSubsectionExtractor()
60
+
61
+ thenSnippetFileExists()
62
+ }
63
+
54
64
@Test
55
65
fun should_document_using_the_passed_raml_snippet () {
56
66
givenEndpointInvoked()
@@ -250,6 +260,39 @@ class MockMvcRestDocumentationWrapperIntegrationTest(@Autowired private val mock
250
260
)
251
261
}
252
262
263
+ @Throws(Exception ::class )
264
+ private fun whenDocumentedWithPayloadSubsectionExtractor () {
265
+ val operationRequestPreprocessor = OperationRequestPreprocessor { r -> r }
266
+ resultActions
267
+ .andDo(
268
+ MockMvcRestDocumentationWrapper .document(
269
+ identifier = operationName,
270
+ privateResource = true ,
271
+ requestPreprocessor = operationRequestPreprocessor,
272
+ snippets = arrayOf(
273
+ requestFields(fieldDescriptors().fieldDescriptors),
274
+ responseFields(
275
+ fieldWithPath(" comment" ).description(" the comment" ),
276
+ fieldWithPath(" flag" ).description(" the flag" ),
277
+ fieldWithPath(" count" ).description(" the count" ),
278
+ fieldWithPath(" id" ).description(" id" ),
279
+ subsectionWithPath(" _links" ).ignored()
280
+ ),
281
+ responseFields(
282
+ beneathPath(" _links" ).withSubsectionId(" beneath-links" ),
283
+ fieldWithPath(" self" ).description(" self link" ),
284
+ fieldWithPath(" self.href" ).description(" self link href" ),
285
+ subsectionWithPath(" multiple" ).ignored(),
286
+ ),
287
+ links(
288
+ linkWithRel(" self" ).description(" some" ),
289
+ linkWithRel(" multiple" ).description(" multiple" )
290
+ )
291
+ )
292
+ )
293
+ )
294
+ }
295
+
253
296
@Throws(Exception ::class )
254
297
private fun whenDocumentedWithResourceSnippetDetails () {
255
298
val operationRequestPreprocessor = OperationRequestPreprocessor { r -> r }
0 commit comments