Giter Club home page Giter Club logo

Comments (8)

wilkinsona avatar wilkinsona commented on August 11, 2024

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.

Thorn1089 avatar Thorn1089 commented on August 11, 2024

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.

wilkinsona avatar wilkinsona commented on August 11, 2024

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.

Thorn1089 avatar Thorn1089 commented on August 11, 2024

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.

Thorn1089 avatar Thorn1089 commented on August 11, 2024

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.

wilkinsona avatar wilkinsona commented on August 11, 2024

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.

CamilYed avatar CamilYed commented on August 11, 2024

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.

wilkinsona avatar wilkinsona commented on August 11, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.