question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rest-Assured - Query string is duplicated in generated snippets

See original GitHub issue

There seems to be a problem with curl- and http-snippet generation. The request params are doubled:

$ curl 'http://loclhost/tags/list?page=0&per_page=3?page=0&per_page=3' -i -H 'Accept: application/json'

GET /tags/list?page=0&per_page=3&page=0&per_page=3 HTTP/1.1 Accept: application/json Host: localhost

I use Rest-Assured:

given(this.spec)
                .accept("application/json")
                .filter(document("tag-list",
                preprocessRequest(prettyPrint(), modifyUris().scheme("http").host("loclhost").removePort()),
                preprocessResponse(prettyPrint()),
                requestParameters(
                        parameterWithName("page").description("Number of the page to retrieve").optional(),
                        parameterWithName("per_page").description("Entries per page").optional()
                ),
                responseFields(
                        fieldWithPath("content").description("Array of elements"),
                        fieldWithPath("totalPages").description("Total number of pages"),
                        fieldWithPath("totalElements").description("Total number of elements"),
                        fieldWithPath("first").description("Is this the first page?"),
                        fieldWithPath("last").description("Is this the last page?"),
                        fieldWithPath("numberOfElements").description("Number of elements on this page"),
                        fieldWithPath("sort").description("Sort order").ignored(),
                        fieldWithPath("size").description("Number of elements on each page"),
                        fieldWithPath("number").description("Page number")
                )))
                .when()
                .port(this.port)
                .get("/tags/list?page=0&per_page=3")
                .then()
                .log().ifValidationFails()
                .time(lessThan(2000L))
                .assertThat().statusCode(200)
                .and()
                .assertThat().contentType("application/json")

Maybe, this is related to #286 ?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
wilkinsonacommented, Sep 7, 2016

Great. Btw, there’s no need for the exclude there. And if you’re using Spring Boot you could just override spring-restdocs.version instead.

1reaction
wilkinsonacommented, Sep 7, 2016

Thanks. Are you using Spring Boot? If so, its dependency management will be forcing the core module (which is where the fix is) to be 1.1.1.RELEASE. If not, please provide a complete example that reproduces the problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring REST Docs duplicates query parameter without value ...
When the request contains a query parameter that has no assigned value (empty string) the snippets produced by CliDocumentation.
Read more >
Rest Assured - Avoid Duplicate code via RequestSpecification ...
In this video I've shown how to avoid duplicate code in Rest Assured using RequestSpecification and ResponseSpecification.
Read more >
spring-projects/spring-restdocs - Gitter
This attribute is user configurable using the $page query parameter (see ... I'm generating my snippets with rest assured in the integration tests....
Read more >
The best way to add a Request Body to a POST request using ...
It's in different ways and one is unanimous: the use of either String or HashMap in the requests. The intention here is to...
Read more >
Spring Cloud Contract Reference Documentation
How Can I Debug the Mapping, Request, or Response Being Sent by WireMock? 8.10. ... How Can I Generate Spring REST Docs Snippets...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found