Class RestDocumentationRequestBuilders
java.lang.Object
org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders
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 TypeMethodDescriptionstatic org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
Create aMockHttpServletRequestBuilder
for a DELETE request.static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
Create aMockHttpServletRequestBuilder
for a DELETE request.static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
Create aMockHttpServletRequestBuilder
for a GET request.static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
Create aMockHttpServletRequestBuilder
for a GET request.static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
Create aMockHttpServletRequestBuilder
for a HEAD request.static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
Create aMockHttpServletRequestBuilder
for a HEAD request.static org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder
Create aMockMultipartHttpServletRequestBuilder
for a multipart request.static org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder
Create aMockMultipartHttpServletRequestBuilder
for a multipart request.static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
Create aMockHttpServletRequestBuilder
for an OPTIONS request.static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
Create aMockHttpServletRequestBuilder
for an OPTIONS request.static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
Create aMockHttpServletRequestBuilder
for a PATCH request.static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
Create aMockHttpServletRequestBuilder
for a PATCH request.static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
Create aMockHttpServletRequestBuilder
for a POST request.static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
Create aMockHttpServletRequestBuilder
for a POST request.static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
Create aMockHttpServletRequestBuilder
for a PUT request.static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
Create aMockHttpServletRequestBuilder
for a PUT request.static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
Create aMockHttpServletRequestBuilder
for a request with the given HTTP method.static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder
Create aMockHttpServletRequestBuilder
for a request with the given HTTP method.
-
Method Details
-
get
public static org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder get(String urlTemplate, Object... urlVariables) Create aMockHttpServletRequestBuilder
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 encodedurlVariables
- 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 aMockHttpServletRequestBuilder
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 aMockHttpServletRequestBuilder
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 encodedurlVariables
- 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 aMockHttpServletRequestBuilder
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 aMockHttpServletRequestBuilder
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 encodedurlVariables
- 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 aMockHttpServletRequestBuilder
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 aMockHttpServletRequestBuilder
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 encodedurlVariables
- 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 aMockHttpServletRequestBuilder
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 aMockHttpServletRequestBuilder
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 encodedurlVariables
- 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 aMockHttpServletRequestBuilder
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 aMockHttpServletRequestBuilder
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 encodedurlVariables
- 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 aMockHttpServletRequestBuilder
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 aMockHttpServletRequestBuilder
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 encodedurlVariables
- 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 aMockHttpServletRequestBuilder
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 aMockHttpServletRequestBuilder
for a request with the given HTTP method. The url template will be captured and made available for documentation.- Parameters:
httpMethod
- the HTTP methodurlTemplate
- a URL template; the resulting URL will be encodedurlVariables
- 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 aMockHttpServletRequestBuilder
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 aMockMultipartHttpServletRequestBuilder
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 encodedurlVariables
- 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 aMockMultipartHttpServletRequestBuilder
for a multipart request.- Parameters:
uri
- the URL- Returns:
- the builder for the multipart request
- Since:
- 2.0.6
-