Class HeaderDocumentation

java.lang.Object
org.springframework.restdocs.headers.HeaderDocumentation

public abstract class HeaderDocumentation extends Object
Static factory methods for documenting a RESTful API's request and response headers.
Author:
Andreas Evers, Andy Wilkinson, Marcel Overdijk
  • Method Details

    • headerWithName

      public static HeaderDescriptor headerWithName(String name)
      Creates a HeaderDescriptor that describes a header with the given name.
      Parameters:
      name - the name of the header
      Returns:
      a HeaderDescriptor ready for further configuration
    • requestHeaders

      public static RequestHeadersSnippet requestHeaders(HeaderDescriptor... descriptors)
      Returns a new Snippet that will document the headers of the API operation's request. The headers will be documented using the given descriptors.

      If a header is documented, is not marked as optional, and is not present in the request, a failure will occur.

      Parameters:
      descriptors - the descriptions of the request's headers
      Returns:
      the snippet that will document the request headers
      See Also:
    • requestHeaders

      public static RequestHeadersSnippet requestHeaders(List<HeaderDescriptor> descriptors)
      Returns a new Snippet that will document the headers of the API operation's request. The headers will be documented using the given descriptors.

      If a header is documented, is not marked as optional, and is not present in the request, a failure will occur.

      Parameters:
      descriptors - the descriptions of the request's headers
      Returns:
      the snippet that will document the request headers
      See Also:
    • requestHeaders

      public static RequestHeadersSnippet requestHeaders(Map<String,Object> attributes, HeaderDescriptor... descriptors)
      Returns a new Snippet that will document the headers of the API operations's request. The given attributes will be available during snippet generation and the headers will be documented using the given descriptors.

      If a header is documented, is not marked as optional, and is not present in the request, a failure will occur.

      Parameters:
      attributes - the attributes
      descriptors - the descriptions of the request's headers
      Returns:
      the snippet that will document the request headers
      See Also:
    • requestHeaders

      public static RequestHeadersSnippet requestHeaders(Map<String,Object> attributes, List<HeaderDescriptor> descriptors)
      Returns a new Snippet that will document the headers of the API operations's request. The given attributes will be available during snippet generation and the headers will be documented using the given descriptors.

      If a header is documented, is not marked as optional, and is not present in the request, a failure will occur.

      Parameters:
      attributes - the attributes
      descriptors - the descriptions of the request's headers
      Returns:
      the snippet that will document the request headers
      See Also:
    • responseHeaders

      public static ResponseHeadersSnippet responseHeaders(HeaderDescriptor... descriptors)
      Returns a new Snippet that will document the headers of the API operation's response. The headers will be documented using the given descriptors.

      If a header is documented, is not marked as optional, and is not present in the request, a failure will occur.

      Parameters:
      descriptors - the descriptions of the response's headers
      Returns:
      the snippet that will document the response headers
      See Also:
    • responseHeaders

      public static ResponseHeadersSnippet responseHeaders(List<HeaderDescriptor> descriptors)
      Returns a new Snippet that will document the headers of the API operation's response. The headers will be documented using the given descriptors.

      If a header is documented, is not marked as optional, and is not present in the request, a failure will occur.

      Parameters:
      descriptors - the descriptions of the response's headers
      Returns:
      the snippet that will document the response headers
      See Also:
    • responseHeaders

      public static ResponseHeadersSnippet responseHeaders(Map<String,Object> attributes, HeaderDescriptor... descriptors)
      Returns a new Snippet that will document the headers of the API operations's response. The given attributes will be available during snippet generation and the headers will be documented using the given descriptors.

      If a header is documented, is not marked as optional, and is not present in the response, a failure will occur.

      Parameters:
      attributes - the attributes
      descriptors - the descriptions of the response's headers
      Returns:
      the snippet that will document the response headers
      See Also:
    • responseHeaders

      public static ResponseHeadersSnippet responseHeaders(Map<String,Object> attributes, List<HeaderDescriptor> descriptors)
      Returns a new Snippet that will document the headers of the API operations's response. The given attributes will be available during snippet generation and the headers will be documented using the given descriptors.

      If a header is documented, is not marked as optional, and is not present in the response, a failure will occur.

      Parameters:
      attributes - the attributes
      descriptors - the descriptions of the response's headers
      Returns:
      the snippet that will document the response headers
      See Also: