Class CookieDocumentation

java.lang.Object
org.springframework.restdocs.cookies.CookieDocumentation

public abstract class CookieDocumentation extends Object
Static factory methods for documenting a RESTful API's request and response cookies.
Since:
3.0
Author:
Clyde Stubbs, Andy Wilkinson
  • Method Details

    • cookieWithName

      public static CookieDescriptor cookieWithName(String name)
      Creates a CookieDescriptor that describes a cookie with the given name.
      Parameters:
      name - the name of the cookie
      Returns:
      a CookieDescriptor ready for further configuration
    • requestCookies

      public static RequestCookiesSnippet requestCookies(CookieDescriptor... descriptors)
      Returns a new Snippet that will document the cookies of the API operation's request. The cookies will be documented using the given descriptors.

      If a cookie is present in the request, but is not documented by one of the descriptors, a failure will occur when the snippet is invoked. Similarly, if a cookie is documented, is not marked as optional, and is not present in the request, a failure will also occur.

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

      public static RequestCookiesSnippet requestCookies(List<CookieDescriptor> descriptors)
      Returns a new Snippet that will document the cookies of the API operation's request. The cookies will be documented using the given descriptors.

      If a cookie is present in the request, but is not documented by one of the descriptors, a failure will occur when the snippet is invoked. Similarly, if a cookie is documented, is not marked as optional, and is not present in the request, a failure will also occur.

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

      public static RequestCookiesSnippet relaxedRequestCookies(CookieDescriptor... descriptors)
      Returns a new Snippet that will document the cookies of the API operation's request. The cookies will be documented using the given descriptors.

      If a cookie is documented, is not marked as optional, and is not present in the request, a failure will occur. Any undocumented cookies will be ignored.

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

      public static RequestCookiesSnippet relaxedRequestCookies(List<CookieDescriptor> descriptors)
      Returns a new Snippet that will document the cookies of the API operation's request. The cookies will be documented using the given descriptors.

      If a cookie is documented, is not marked as optional, and is not present in the request, a failure will occur. Any undocumented cookies will be ignored.

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

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

      If a cookie is present in the request, but is not documented by one of the descriptors, a failure will occur when the snippet is invoked. Similarly, if a cookie is documented, is not marked as optional, and is not present in the request, a failure will also occur.

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

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

      If a cookie is present in the request, but is not documented by one of the descriptors, a failure will occur when the snippet is invoked. Similarly, if a cookie is documented, is not marked as optional, and is not present in the request, a failure will also occur.

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

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

      If a cookie is documented, is not marked as optional, and is not present in the request, a failure will occur. Any undocumented cookies will be ignored.

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

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

      If a cookie is documented, is not marked as optional, and is not present in the request, a failure will occur. Any undocumented cookies will be ignored.

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

      public static ResponseCookiesSnippet responseCookies(CookieDescriptor... descriptors)
      Returns a new Snippet that will document the cookies of the API operation's response. The cookies will be documented using the given descriptors.

      If a cookie is present in the response, but is not documented by one of the descriptors, a failure will occur when the snippet is invoked. Similarly, if a cookie is documented, is not marked as optional, and is not present in the response, a failure will also occur.

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

      public static ResponseCookiesSnippet responseCookies(List<CookieDescriptor> descriptors)
      Returns a new Snippet that will document the cookies of the API operation's response. The cookies will be documented using the given descriptors.

      If a cookie is present in the response, but is not documented by one of the descriptors, a failure will occur when the snippet is invoked. Similarly, if a cookie is documented, is not marked as optional, and is not present in the response, a failure will also occur.

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

      public static ResponseCookiesSnippet relaxedResponseCookies(CookieDescriptor... descriptors)
      Returns a new Snippet that will document the cookies of the API operation's response. The cookies will be documented using the given descriptors.

      If a cookie is documented, is not marked as optional, and is not present in the response, a failure will occur. Any undocumented cookies will be ignored.

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

      public static ResponseCookiesSnippet relaxedResponseCookies(List<CookieDescriptor> descriptors)
      Returns a new Snippet that will document the cookies of the API operation's response. The cookies will be documented using the given descriptors.

      If a cookie is documented, is not marked as optional, and is not present in the response, a failure will occur. Any undocumented cookies will be ignored.

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

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

      If a cookie is present in the response, but is not documented by one of the descriptors, a failure will occur when the snippet is invoked. Similarly, if a cookie is documented, is not marked as optional, and is not present in the response, a failure will also occur.

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

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

      If a cookie is present in the response, but is not documented by one of the descriptors, a failure will occur when the snippet is invoked. Similarly, if a cookie is documented, is not marked as optional, and is not present in the response, a failure will also occur.

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

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

      If a cookie is documented, is not marked as optional, and is not present in the response, a failure will occur. Any undocumented cookies will be ignored.

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

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

      If a cookie is documented, is not marked as optional, and is not present in the response, a failure will occur. Any undocumented cookies will be ignored.

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