@@ -17,6 +17,7 @@ import org.springframework.restdocs.hypermedia.HypermediaDocumentation.links
1717import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document
1818import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post
1919import org.springframework.restdocs.operation.preprocess.OperationRequestPreprocessor
20+ import org.springframework.restdocs.payload.PayloadDocumentation.beneathPath
2021import org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath
2122import org.springframework.restdocs.payload.PayloadDocumentation.requestFields
2223import org.springframework.restdocs.payload.PayloadDocumentation.responseFields
@@ -51,6 +52,15 @@ class MockMvcRestDocumentationWrapperIntegrationTest(@Autowired private val mock
5152 thenSnippetFileExists()
5253 }
5354
55+ @Test
56+ fun should_document_both_restdocs_and_resource_with_path () {
57+ givenEndpointInvoked()
58+
59+ whenDocumentedWithPayloadSubsectionExtractor()
60+
61+ thenSnippetFileExists()
62+ }
63+
5464 @Test
5565 fun should_document_using_the_passed_raml_snippet () {
5666 givenEndpointInvoked()
@@ -250,6 +260,39 @@ class MockMvcRestDocumentationWrapperIntegrationTest(@Autowired private val mock
250260 )
251261 }
252262
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+
253296 @Throws(Exception ::class )
254297 private fun whenDocumentedWithResourceSnippetDetails () {
255298 val operationRequestPreprocessor = OperationRequestPreprocessor { r -> r }
0 commit comments