Fix handling of empty querty string parameters
Previously empty parameters in a query string were handled inconsistently such that they sometimes had a value of "" in a list and sometimes were represented as an empty list. This inconsistency lead to the parameter appearing twice in the cURL request snippet. This commit removes the inconsistency by always using an empty string to represent an empty query parameter value. Fixes gh-647
This commit is contained in:
@@ -165,6 +165,17 @@ public class WebTestClientRestDocumentationIntegrationTests {
|
||||
+ " -H 'Accept: application/json' \\%n" + " --cookie 'cookieName=cookieVal'"))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void curlSnippetWithEmptyParameterQueryString() throws Exception {
|
||||
this.webTestClient.get().uri("/?a=").accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk()
|
||||
.expectBody().consumeWith(document("curl-snippet-with-empty-parameter-query-string"));
|
||||
assertThat(
|
||||
new File("build/generated-snippets/curl-snippet-with-empty-parameter-query-string/curl-request.adoc"))
|
||||
.has(content(codeBlock(TemplateFormats.asciidoctor(), "bash")
|
||||
.withContent(String.format("$ curl 'https://api.example.com/?a=' -i -X GET \\%n"
|
||||
+ " -H 'Accept: application/json'"))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void httpieSnippetWithCookies() throws Exception {
|
||||
this.webTestClient.get().uri("/").cookie("cookieName", "cookieVal").accept(MediaType.APPLICATION_JSON)
|
||||
|
||||
Reference in New Issue
Block a user