Skip to content

Commit

Permalink
Document how to specify query parameters when testing with MockMvc
Browse files Browse the repository at this point in the history
Closes gh-926
  • Loading branch information
wilkinsona committed May 7, 2024
1 parent d4bb3b3 commit b6df324
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/src/docs/asciidoc/documenting-your-api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -661,11 +661,13 @@ The following examples show how to do so:
include::{examples-dir}/com/example/mockmvc/QueryParameters.java[tags=query-parameters]
----
<1> Perform a `GET` request with two parameters, `page` and `per_page`, in the query string.
Query parameters should be included in the URL, as shown here, or specified using the request builder's `queryParam` or `queryParams` method.
The `param` and `params` methods should be avoided as the source of the parameters is then ambiguous.
<2> Configure Spring REST Docs to produce a snippet describing the request's query parameters.
Uses the static `queryParameters` method on `org.springframework.restdocs.request.RequestDocumentation`.
<3> Document the `page` parameter.
<3> Document the `page` query parameter.
Uses the static `parameterWithName` method on `org.springframework.restdocs.request.RequestDocumentation`.
<4> Document the `per_page` parameter.
<4> Document the `per_page` query parameter.

[source,java,indent=0,role="secondary"]
.WebTestClient
Expand Down

0 comments on commit b6df324

Please sign in to comment.