java.lang.Object
org.springframework.restdocs.operation.preprocess.Preprocessors

public final class Preprocessors extends Object
Static factory methods for creating OperationPreprocessors that can be applied to an Operation's request or response before it is documented.
Author:
Andy Wilkinson, Roland Huss
  • Method Details

    • preprocessRequest

      public static OperationRequestPreprocessor preprocessRequest(OperationPreprocessor... preprocessors)
      Returns an OperationRequestPreprocessor that will preprocess the request by applying the given preprocessors to it.
      Parameters:
      preprocessors - the preprocessors
      Returns:
      the request preprocessor
    • preprocessResponse

      public static OperationResponsePreprocessor preprocessResponse(OperationPreprocessor... preprocessors)
      Returns an OperationResponsePreprocessor that will preprocess the response by applying the given preprocessors to it.
      Parameters:
      preprocessors - the preprocessors
      Returns:
      the response preprocessor
    • prettyPrint

      public static OperationPreprocessor prettyPrint()
      Returns an OperationPreprocessor that will pretty print the content of the request or response.
      Returns:
      the preprocessor
    • removeHeaders

      public static OperationPreprocessor removeHeaders(String... headerNames)
      Returns an OperationPreprocessor that will remove any header from the request or response with a name that is equal to one of the given headersToRemove.
      Parameters:
      headerNames - the header names
      Returns:
      the preprocessor
      See Also:
    • removeMatchingHeaders

      public static OperationPreprocessor removeMatchingHeaders(String... headerNamePatterns)
      Returns an OperationPreprocessor that will remove any headers from the request or response with a name that matches one of the given headerNamePatterns regular expressions.
      Parameters:
      headerNamePatterns - the header name patterns
      Returns:
      the preprocessor
      See Also:
    • maskLinks

      public static OperationPreprocessor maskLinks()
      Returns an OperationPreprocessor that will mask the href of hypermedia links in the request or response.
      Returns:
      the preprocessor
    • maskLinks

      public static OperationPreprocessor maskLinks(String mask)
      Returns an OperationPreprocessor that will mask the href of hypermedia links in the request or response.
      Parameters:
      mask - the link mask
      Returns:
      the preprocessor
    • replacePattern

      public static OperationPreprocessor replacePattern(Pattern pattern, String replacement)
      Returns an OperationPreprocessor that will modify the content of the request or response by replacing occurrences of the given pattern with the given replacement.
      Parameters:
      pattern - the pattern
      replacement - the replacement
      Returns:
      the preprocessor
    • modifyParameters

      public static ParametersModifyingOperationPreprocessor modifyParameters()
      Returns a ParametersModifyingOperationPreprocessor that can then be configured to modify the parameters of the request.
      Returns:
      the preprocessor
      Since:
      1.1.0
    • modifyUris

      public static UriModifyingOperationPreprocessor modifyUris()
      Returns a UriModifyingOperationPreprocessor that will modify URIs in the request or response by changing one or more of their host, scheme, and port.
      Returns:
      the preprocessor
      Since:
      2.0.1