Class RestDocumentationResultHandler
java.lang.Object
org.springframework.restdocs.mockmvc.RestDocumentationResultHandler
- All Implemented Interfaces:
org.springframework.test.web.servlet.ResultHandler
public class RestDocumentationResultHandler
extends Object
implements org.springframework.test.web.servlet.ResultHandler
A Spring MVC Test
ResultHandler
for documenting RESTful APIs.- Author:
- Andy Wilkinson, Andreas Evers
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionCreates a newRestDocumentationResultHandler
to be passed intoResultActions.andDo(ResultHandler)
that will produce documentation using the givensnippets
.protected final RestDocumentationGenerator<org.springframework.mock.web.MockHttpServletRequest,
org.springframework.mock.web.MockHttpServletResponse> Returns theRestDocumentationGenerator
that is used as a delegate.void
handle
(org.springframework.test.web.servlet.MvcResult result)
-
Method Details
-
handle
public void handle(org.springframework.test.web.servlet.MvcResult result) - Specified by:
handle
in interfaceorg.springframework.test.web.servlet.ResultHandler
-
document
Creates a newRestDocumentationResultHandler
to be passed intoResultActions.andDo(ResultHandler)
that will produce documentation using the givensnippets
. For example:this.mockMvc.perform(MockMvcRequestBuilders.get("/search")) .andExpect(status().isOk()) .andDo(this.documentationHandler.document(responseFields( fieldWithPath("page").description("The requested Page") ));
- Parameters:
snippets
- the snippets- Returns:
- the new result handler
-
getDelegate
protected final RestDocumentationGenerator<org.springframework.mock.web.MockHttpServletRequest,org.springframework.mock.web.MockHttpServletResponse> getDelegate()Returns theRestDocumentationGenerator
that is used as a delegate.- Returns:
- the delegate
-