title: Special characters in @QueryParam name in Spring feign client
body: <p>One of our external API uses query param names with special characters (don't ask me why, I don't know). My feign client's method for this API is declared like this:</p>
  
  <pre><code>@GetMapping("/v1/user/{userId}/orders")
  List&lt;Order&gt; getOrders(
      @PathVariable("userId") String userId,
      @RequestParam("page[number]") Integer pageNumber,
      @RequestParam("page[size]") Integer pageSize);
  </code></pre>
  
  <p>As I mentioned, request params contain special characters <code>[</code> and <code>]</code>.
  I'm using Spock for testing and I want to set up Wiremock stub like this:</p>
  
  <pre><code>wiremock.stubFor(
    get(urlPathMatching('/v1/users/' + userId + '/orders'))
      .withQueryParam("page[number]", new EqualToPattern("1"))
      .withQueryParam("page[size]", new AnythingPattern())
      .willReturn(
        status(200)
          .withHeader("Content-type", "application/json")
          .withBody("""[]""")
      ))
  </code></pre>
  
  <p>But I get:</p>
  
  <pre><code>--------------------------------------------------------------------------------------------------
  | Closest stub                        | Request                                                  |
  --------------------------------------------------------------------------------------------------
                                        |
  GET                                   | GET
  /v1/users/123/orders                  | /v1/users/123/orders?page%5Bnumber%5D=%7Bpage%5Bnumber%5
                                        | D%7D&amp;page%5Bsize%5D=%7Bpage%5Bsize%5D%7D
                                        |
  Query: page[number] = 1               |                                 &lt;&lt;&lt;&lt;&lt; Query is not present
  Query: page[size] [anything] (always) |                                 &lt;&lt;&lt;&lt;&lt; Query is not present
                                        |
  --------------------------------------------------------------------------------------------------
  </code></pre>
  
  <p>After lots of trials and errors, I came up with a solution to use <code>@PathVariable</code>s instead of <code>@RequestParam</code>s in feign client method:</p>
  
  <pre><code>@GetMapping("/v1/users/{userId}/orders?page[number]={pageNumber}&amp;page[size]={pageSize}")
  List&lt;Order&gt; getOrders(
      @PathVariable("userId") String userId,
      @PathVariable("pageNumber") Integer pageNumber,
      @PathVariable("pageSize") Integer pageSize);
  </code></pre>
  
  <p>and encode all query params in Wiremock</p>
  
  <pre><code>wiremock.stubFor(
      get(urlPathMatching('/v1/users/' + userId + '/orders'))
      .withQueryParam("page%5Bnumber%5D", new EqualToPattern("1"))
      .withQueryParam("page%5Bsize%5D", new AnythingPattern())
      .willReturn(
          status(200)
          .withHeader("Content-type", "application/json")
          .withBody("""[]""")
      ))
  </code></pre>
  
  <p>Then it works. But it looks like a kind of a hack. It is problematic to use an optional query params as well.</p>
  
  <p>Is there a way to use <code>@RequestParam</code>s with special characters?
  It looks like a bug in Spring?</p>
  
  <p>In the mean time I will try to debug it to understand where is the problem.</p>