Class RestDocumentationRequestBuilders

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

public abstract class RestDocumentationRequestBuilders extends Object
A drop-in replacement for MockMvcRequestBuilders that captures a request's URL template and makes it available for documentation. Required when ) documenting path parameters and recommended for general usage.
Author:
Andy Wilkinson
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
    delete(String urlTemplate, Object... urlVariables)
    Create a MockHttpServletRequestBuilder for a DELETE request.
    static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
    delete(URI uri)
    Create a MockHttpServletRequestBuilder for a DELETE request.
    static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
    get(String urlTemplate, Object... urlVariables)
    Create a MockHttpServletRequestBuilder for a GET request.
    static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
    get(URI uri)
    Create a MockHttpServletRequestBuilder for a GET request.
    static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
    head(String urlTemplate, Object... urlVariables)
    Create a MockHttpServletRequestBuilder for a HEAD request.
    static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
    head(URI uri)
    Create a MockHttpServletRequestBuilder for a HEAD request.
    static org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder
    multipart(String urlTemplate, Object... urlVariables)
    Create a MockMultipartHttpServletRequestBuilder for a multipart request.
    static org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder
    Create a MockMultipartHttpServletRequestBuilder for a multipart request.
    static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
    options(String urlTemplate, Object... urlVariables)
    Create a MockHttpServletRequestBuilder for an OPTIONS request.
    static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
    options(URI uri)
    Create a MockHttpServletRequestBuilder for an OPTIONS request.
    static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
    patch(String urlTemplate, Object... urlVariables)
    Create a MockHttpServletRequestBuilder for a PATCH request.
    static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
    patch(URI uri)
    Create a MockHttpServletRequestBuilder for a PATCH request.
    static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
    post(String urlTemplate, Object... urlVariables)
    Create a MockHttpServletRequestBuilder for a POST request.
    static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
    post(URI uri)
    Create a MockHttpServletRequestBuilder for a POST request.
    static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
    put(String urlTemplate, Object... urlVariables)
    Create a MockHttpServletRequestBuilder for a PUT request.
    static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
    put(URI uri)
    Create a MockHttpServletRequestBuilder for a PUT request.
    static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
    request(org.springframework.http.HttpMethod httpMethod, String urlTemplate, Object... urlVariables)
    Create a MockHttpServletRequestBuilder for a request with the given HTTP method.
    static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
    request(org.springframework.http.HttpMethod httpMethod, URI uri)
    Create a MockHttpServletRequestBuilder for a request with the given HTTP method.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • get

      public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder get(String urlTemplate, Object... urlVariables)
      Create a MockHttpServletRequestBuilder for a GET request. The url template will be captured and made available for documentation.
      Parameters:
      urlTemplate - a URL template; the resulting URL will be encoded
      urlVariables - zero or more URL variables
      Returns:
      the builder for the GET request
    • get

      public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder get(URI uri)
      Create a MockHttpServletRequestBuilder for a GET request.
      Parameters:
      uri - the URL
      Returns:
      the builder for the GET request
    • post

      public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder post(String urlTemplate, Object... urlVariables)
      Create a MockHttpServletRequestBuilder for a POST request. The url template will be captured and made available for documentation.
      Parameters:
      urlTemplate - a URL template; the resulting URL will be encoded
      urlVariables - zero or more URL variables
      Returns:
      the builder for the POST request
    • post

      public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder post(URI uri)
      Create a MockHttpServletRequestBuilder for a POST request.
      Parameters:
      uri - the URL
      Returns:
      the builder for the POST request
    • put

      public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder put(String urlTemplate, Object... urlVariables)
      Create a MockHttpServletRequestBuilder for a PUT request. The url template will be captured and made available for documentation.
      Parameters:
      urlTemplate - a URL template; the resulting URL will be encoded
      urlVariables - zero or more URL variables
      Returns:
      the builder for the PUT request
    • put

      public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder put(URI uri)
      Create a MockHttpServletRequestBuilder for a PUT request.
      Parameters:
      uri - the URL
      Returns:
      the builder for the PUT request
    • patch

      public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder patch(String urlTemplate, Object... urlVariables)
      Create a MockHttpServletRequestBuilder for a PATCH request. The url template will be captured and made available for documentation.
      Parameters:
      urlTemplate - a URL template; the resulting URL will be encoded
      urlVariables - zero or more URL variables
      Returns:
      the builder for the PATCH request
    • patch

      public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder patch(URI uri)
      Create a MockHttpServletRequestBuilder for a PATCH request.
      Parameters:
      uri - the URL
      Returns:
      the builder for the PATCH request
    • delete

      public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder delete(String urlTemplate, Object... urlVariables)
      Create a MockHttpServletRequestBuilder for a DELETE request. The url template will be captured and made available for documentation.
      Parameters:
      urlTemplate - a URL template; the resulting URL will be encoded
      urlVariables - zero or more URL variables
      Returns:
      the builder for the DELETE request
    • delete

      public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder delete(URI uri)
      Create a MockHttpServletRequestBuilder for a DELETE request.
      Parameters:
      uri - the URL
      Returns:
      the builder for the DELETE request
    • options

      public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder options(String urlTemplate, Object... urlVariables)
      Create a MockHttpServletRequestBuilder for an OPTIONS request. The url template will be captured and made available for documentation.
      Parameters:
      urlTemplate - a URL template; the resulting URL will be encoded
      urlVariables - zero or more URL variables
      Returns:
      the builder for the OPTIONS request
    • options

      public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder options(URI uri)
      Create a MockHttpServletRequestBuilder for an OPTIONS request.
      Parameters:
      uri - the URL
      Returns:
      the builder for the OPTIONS request
    • head

      public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder head(String urlTemplate, Object... urlVariables)
      Create a MockHttpServletRequestBuilder for a HEAD request. The url template will be captured and made available for documentation.
      Parameters:
      urlTemplate - a URL template; the resulting URL will be encoded
      urlVariables - zero or more URL variables
      Returns:
      the builder for the HEAD request
    • head

      public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder head(URI uri)
      Create a MockHttpServletRequestBuilder for a HEAD request.
      Parameters:
      uri - the URL
      Returns:
      the builder for the HEAD request
    • request

      public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder request(org.springframework.http.HttpMethod httpMethod, String urlTemplate, Object... urlVariables)
      Create a MockHttpServletRequestBuilder for a request with the given HTTP method. The url template will be captured and made available for documentation.
      Parameters:
      httpMethod - the HTTP method
      urlTemplate - a URL template; the resulting URL will be encoded
      urlVariables - zero or more URL variables
      Returns:
      the builder for the request
    • request

      public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder request(org.springframework.http.HttpMethod httpMethod, URI uri)
      Create a MockHttpServletRequestBuilder for a request with the given HTTP method.
      Parameters:
      httpMethod - the HTTP method (GET, POST, etc)
      uri - the URL
      Returns:
      the builder for the request
    • multipart

      public static org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder multipart(String urlTemplate, Object... urlVariables)
      Create a MockMultipartHttpServletRequestBuilder for a multipart request. The URL template will be captured and made available for documentation.
      Parameters:
      urlTemplate - a URL template; the resulting URL will be encoded
      urlVariables - zero or more URL variables
      Returns:
      the builder for the multipart request
      Since:
      2.0.6
    • multipart

      public static org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder multipart(URI uri)
      Create a MockMultipartHttpServletRequestBuilder for a multipart request.
      Parameters:
      uri - the URL
      Returns:
      the builder for the multipart request
      Since:
      2.0.6