Closed
Description
I'm using Spring REST Docs (2.0.3.RELEASE) and MockMvc (spring-test 5.0.5.RELEASE).
When the documented request contains a query parameter that has no assigned value (empty string) the snippets produced by CliDocumentation.curlRequest()
and HttpDocumentation.httpRequest()
show the parameter duplicated.
My setup:
@Before
public void setUp() {
this.documentationHandler = document("{class-name}/{method-name}",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()));
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
.defaultRequest(get("/")
.contextPath(contextPath))
.apply(documentationConfiguration(this.restDocumentation).uris()
.withScheme(scheme)
.withHost(host)
.withPort(port))
.alwaysDo(this.documentationHandler)
.build();
}
My test:
@Test
public void getBookDescriptionNullCodeTest() throws Exception {
this.mockMvc.perform(
get("/my.app/{catalogue}/$lookup", "books").param("code", "")
.contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(status().isUnprocessableEntity())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
...
The curl snippet (note the ?code=&code=
):
[source,bash]
----
$ curl 'http://localhost:8080/my.app/books/$lookup?code=&code=' -i -X GET \
-H 'Content-Type: application/json;charset=UTF-8'
----
This appears to be similar to #286, however this only happens for valueless parameters and that bug was fixed in version 1.1.2.RELEASE.