Skip to content

Duplicated request parameters in code snippets #287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Simonowicz opened this issue Aug 4, 2016 · 1 comment
Closed

Duplicated request parameters in code snippets #287

Simonowicz opened this issue Aug 4, 2016 · 1 comment
Labels
status: duplicate Duplicate of another issue

Comments

@Simonowicz
Copy link

Hi!

I'm using spring-restdocs-restassured version 1.1.1.RELEASE to document my endpoints. Unfortunately, I've run into problem with request parameters being duplicated in generated code snippets. Here's the code I'm using:

RestAssured.given(this.spec)
            .auth().preemptive().oauth2(validAccessToken)
            .accept("application/json")
            .filter(document("activities",
                        preprocessRequest(prettyPrint(), modifyUris().scheme(scheme).host(host).removePort(), maskAuthorization()),
                        preprocessResponse(prettyPrint(), modifyUris().scheme(scheme).host(host).removePort()),
                        requestParameters(
                                parameterWithName("activityType").description("Type of activities to return"),
                                parameterWithName("pageNumber").description("Page number to retrieve"),
                                parameterWithName("start").description("Timestamp defining start time").optional()
                        ),
                        requestHeaders(headerWithName("Authorization").description("A valid access token")),
                        responseFields(
                                ...
                        )
                    )
            )
                .param("activityType", "GRADING")
                .param("pageNumber", 1)
                .param("start", "2016-01-15 00:00:00")
            .when()
                .get(ApiVersion.ApiVersionType.V1.getVersion() + ActivityController.ACTIVITIES_PATH)
            .then()
                .statusCode(200);

As a result I receive the following curl code snippet:

[source,bash]
----
$ curl 'https://host.com/v1/activities?activityType=GRADING&pageNumber=1&start=2016-01-15%2000%3A00%3A00?activityType=GRADING&pageNumber=1&start=2016-01-15+00%3A00%3A00' -i -H 'Authorization: Bearer {your access token}' -H 'Accept: application/json'
----

Same applies for http-request snippet:

[source,http,options="nowrap"]
----
GET /v1/activities?activityType=GRADING&pageNumber=1&start=2016-01-15%2000%3A00%3A00&activityType=GRADING&pageNumber=1&start=2016-01-15+00%3A00%3A00 HTTP/1.1
Authorization: Bearer {your access token}
Accept: application/json
Host: host.com

----

Surprisingly httpie-request is correct:

[source,bash]
----
$ http GET 'https://webapi.samsungschool.com/v1/activities?activityType=GRADING&pageNumber=1&start=2016-01-15%2000%3A00%3A00' 'Authorization:Bearer {your access token}' 'Accept:application/json'
----

I've also tried different variants of the code I provided, placing query parameters in the get() String directly as well as placing param() in when() RequestSpecification. Am I missing something or is this a bug?

Thanks in advance for your assistance.

@wilkinsona
Copy link
Member

Duplicates #286

@wilkinsona wilkinsona added the status: duplicate Duplicate of another issue label Aug 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate Duplicate of another issue
Projects
None yet
Development

No branches or pull requests

2 participants