Class MockMvcRestDocumentation

java.lang.Object
org.springframework.restdocs.mockmvc.MockMvcRestDocumentation

public abstract class MockMvcRestDocumentation extends Object
Static factory methods for documenting RESTful APIs using Spring MVC Test.
Author:
Andy Wilkinson
  • Method Details

    • documentationConfiguration

      public static MockMvcRestDocumentationConfigurer documentationConfiguration(RestDocumentationContextProvider contextProvider)
      Provides access to a MockMvcConfigurer that can be used to configure a MockMvc instance using the given contextProvider.
      Parameters:
      contextProvider - the context provider
      Returns:
      the configurer
      See Also:
      • ConfigurableMockMvcBuilder.apply(MockMvcConfigurer)
    • document

      public static RestDocumentationResultHandler document(String identifier, Snippet... snippets)
      Documents the API call with the given identifier using the given snippets in addition to any default snippets.
      Parameters:
      identifier - an identifier for the API call that is being documented
      snippets - the snippets
      Returns:
      a Mock MVC ResultHandler that will produce the documentation
      See Also:
      • MockMvc.perform(org.springframework.test.web.servlet.RequestBuilder)
      • ResultActions.andDo(org.springframework.test.web.servlet.ResultHandler)
    • document

      public static RestDocumentationResultHandler document(String identifier, OperationRequestPreprocessor requestPreprocessor, Snippet... snippets)
      Documents the API call with the given identifier using the given snippets in addition to any default snippets. The given requestPreprocessor is applied to the request before it is documented.
      Parameters:
      identifier - an identifier for the API call that is being documented
      requestPreprocessor - the request preprocessor
      snippets - the snippets
      Returns:
      a Mock MVC ResultHandler that will produce the documentation
      See Also:
      • MockMvc.perform(org.springframework.test.web.servlet.RequestBuilder)
      • ResultActions.andDo(org.springframework.test.web.servlet.ResultHandler)
    • document

      public static RestDocumentationResultHandler document(String identifier, OperationResponsePreprocessor responsePreprocessor, Snippet... snippets)
      Documents the API call with the given identifier using the given snippets in addition to any default snippets. The given responsePreprocessor is applied to the request before it is documented.
      Parameters:
      identifier - an identifier for the API call that is being documented
      responsePreprocessor - the response preprocessor
      snippets - the snippets
      Returns:
      a Mock MVC ResultHandler that will produce the documentation
      See Also:
      • MockMvc.perform(org.springframework.test.web.servlet.RequestBuilder)
      • ResultActions.andDo(org.springframework.test.web.servlet.ResultHandler)
    • document

      public static RestDocumentationResultHandler document(String identifier, OperationRequestPreprocessor requestPreprocessor, OperationResponsePreprocessor responsePreprocessor, Snippet... snippets)
      Documents the API call with the given identifier using the given snippets in addition to any default snippets. The given requestPreprocessor and responsePreprocessor are applied to the request and response respectively before they are documented.
      Parameters:
      identifier - an identifier for the API call that is being documented
      requestPreprocessor - the request preprocessor
      responsePreprocessor - the response preprocessor
      snippets - the snippets
      Returns:
      a Mock MVC ResultHandler that will produce the documentation
      See Also:
      • MockMvc.perform(org.springframework.test.web.servlet.RequestBuilder)
      • ResultActions.andDo(org.springframework.test.web.servlet.ResultHandler)