Class RestDocumentationResultHandler

java.lang.Object
org.springframework.restdocs.mockmvc.RestDocumentationResultHandler
All Implemented Interfaces:
ResultHandler

public class RestDocumentationResultHandler extends Object implements ResultHandler
A Spring MVC Test ResultHandler for documenting RESTful APIs.
Author:
Andy Wilkinson, Andreas Evers
See Also:
  • Method Details

    • handle

      public void handle(MvcResult result)
      Specified by:
      handle in interface ResultHandler
    • document

      public RestDocumentationResultHandler document(org.springframework.restdocs.snippet.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 org.springframework.restdocs.generate.RestDocumentationGenerator<MockHttpServletRequest,MockHttpServletResponse> getDelegate()
      Returns the RestDocumentationGenerator that is used as a delegate.
      Returns:
      the delegate