title: REST API design - optional request parameters
body: <p>I've written this request mapping to access a ticket by it's id:</p>
  
  <pre><code>@GetMapping(path = "/tickets/{ticketId}")
     @ResponseStatus(value = HttpStatus.OK)
      public ResponseEntity&lt;List&lt;TicketResponse&gt;&gt; getTicketsById(@PathVariable("ticketId") final Long ticketId
  </code></pre>
  
  <p>I'm planning to add multiple query parameters to support filtering such as ticketType, ticketStatus. REST API users should have options to filter on any or all of the query parameters.</p>
  
  <p>What are the REST API design principles to achieve this ? Should I add new request parameters to support the filtering like below ? :</p>
  
  <pre><code>@GetMapping(path = "/tickets/{ticketId}")
     @ResponseStatus(value = HttpStatus.OK)
      public ResponseEntity&lt;List&lt;TicketResponse&gt;&gt; getTicketsById(@PathVariable("ticketId") final Long ticketId, @RequestParam("ticketType") final String ticketType, @RequestParam("ticketStatus") final String ticketStatus)
  </code></pre>
  
  <p>Is there a Spring design pattern for this scenario ? The Java builder pattern could be used where parameter an attribute of a QueryParameter object ? </p>