Comments (8)
The relationship between request parameters and a URI's query string is a little bit tricky and, at the moment, Spring REST Docs only looks at the query string (HttpServletRequest.getQueryString()
), whereas the param(key, value)
method only makes them available from ServletRequest.getParameterMap()
. The latter contains parameters both from the query string and from POSTed form data. Rather than trying to separate out the query string parameters, Spring REST docs just looks at the request's query string. Looks like we need to improve this and look in the parameter map when it's a GET
request.
In the meantime, updating your test to look like the following should produce the desired snippet:
@Test
public void testSearchingRoutes() throws Exception {
mockMvc.perform(get("/routes?startNear=+42.297877,-71.485591&endNear=+41.949915,-71.406392"))
.andExpect(status().isOk())
.andDo(document("search-routes-example"));
}
from spring-restdocs.
I tried that first, with no luck, hence why I assumed I needed separate calls to param
(hadn't used MockMvc before now).
Digging a little more into the code, I see
this.writer.print(String.format("curl %s://%s:%d%s", request.getScheme(),
request.getRemoteHost(), request.getRemotePort(),
request.getRequestURI()));
in the CurlRequestDocumentationAction
class. Seems like the query string is omitted from the format string as it's built up. Any technical reason for this, or is it just an oversight? If the latter, I'll try to throw together a pull request.
from spring-restdocs.
That looks like you're missing the changes made in 6bdd60c. Perhaps you need to give Maven or Gradle a nudge to get it to refresh snapshot dependencies?
from spring-restdocs.
Aha, thanks!
On Mar 2, 2015 6:20 AM, "Andy Wilkinson" [email protected] wrote:
That looks like your missing the changes made in 6bdd60c
6bdd60c.
Perhaps you need to give Maven or Gradle a nudge to get it to refresh
snapshot dependencies?—
Reply to this email directly or view it on GitHub
#26 (comment)
.
from spring-restdocs.
Took a look at Artifactory on repo.spring.io -- looks like that commit isn't in the most recent snapshot. Still, glad to know it'll be in the next update.
from spring-restdocs.
The changes should be in the latest snapshots as they're automatically published by the CI server. The artifact's coordinates changed from org.springframework.restdocs:spring-restdocs-core
to org.springframework.restdocs:spring-restdocs
recently. Perhaps you were looking at the old artifact? I've just deleted the old snapshots from the repo to hopefully make the name change a little more obvious.
from spring-restdocs.
I have a problem whean I want to pass to my controller method a DTO object as query parameter.
In my test the parameters are not resolved , and my object have a null fields...
from spring-restdocs.
@KamilJedrzejuk That sounds like a problem with how you're making the request which is out of REST Docs' control. Perhaps you could ask a question on Stack Overflow that includes an example of how you're making the request and the controller that is receiving it.
from spring-restdocs.
Related Issues (20)
- Upgrade to Spring Java Format 0.0.39
- Upgrade to Spring Framework 6.0.14
- Perform compatibility testing against Framework 6.1
- UnsupportedOperationException when modifying request and response headers with Framework 6.0.9 and later
- Avoid substring creation when writing a portion of a string to a StringBuilder
- How to hide Request Body and curl particular fields like "Token"? while generating spring rest docs through rest assured approach HOT 1
- Request-body.adoc is coming as blank in case of get call HOT 3
- Except body fields how can I add others mandate fields like headers(correlationId, destination, srDate) HOT 1
- Getting issue related to query parameter. HOT 5
- Latest dependencies issue is coming while generating rest docs HOT 2
- Any concern that the underlying asciidoc gradle plugin doesn't work with Java 17 or 21? HOT 1
- Upgrade Gradle Enterprise Plugins
- Using JWT Token to Access Resource Server HOT 2
- Cannot document form parameters when using Rest Assured's MockMvc support when contentType is multipart/form-data HOT 5
- Upgrade to Gradle Enterprise Conventions 0.0.16
- Move to GitHub Actions to build and deploy snapshots
- Run Windows and Java compatibility builds on GitHub Actions
- Document that the query string should be provided in the URL or by using queryParam when using MockMvc HOT 1
- JavaDoc support HOT 1
- Upgrade to Gradle Enterprise Conventions 0.0.17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-restdocs.