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 Details

    • handle

      public void handle(org.springframework.test.web.servlet.MvcResult result)
      Specified by:
      handle in interface org.springframework.test.web.servlet.ResultHandler
    • document

      public RestDocumentationResultHandler document(Snippet... snippets)
      Creates a new RestDocumentationResultHandler to be passed into ResultActions.andDo(ResultHandler) that will produce documentation using the given snippets. 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 the RestDocumentationGenerator that is used as a delegate.
      Returns:
      the delegate