title: Optional query string enum parameter - openapi, springboot
body: <p>I have an OpenApi spec:</p>
  
  <pre><code>paths:
    /lessons:
      get:
        tags:
          - lesson
        operationId: getLessons
        parameters:
          - in: query
            name: daysOfWeek
            schema:
              type: array
              items:
                $ref: '#/components/schemas/DaysOfWeekEnum'
  </code></pre>
  
  <p>Using swagger codegen this generates an endpoint like: </p>
  
  <pre><code> @ApiOperation(value = "Get a collection lessons", nickname = "getLessons", notes = "", response = LessonDto.class, responseContainer = "List", tags={ "lesson", })
      @ApiResponses(value = { 
          @ApiResponse(code = 200, message = "List of Lessons", response = LessonDto.class, responseContainer = "List") })
      @RequestMapping(value = "/lessons",
          produces = { "application/json" }, 
          method = RequestMethod.GET)
      default ResponseEntity&lt;List&lt;LessonDto&gt;&gt; _getLessons(@ApiParam(removed for brevity) @Valid @RequestParam(value = "daysOfWeek", required = false, defaultValue="new ArrayList&lt;&gt;()") List&lt;DaysOfWeekEnum&gt; daysOfWeek) {
          return getLessons(daysOfWeek);
      }
  </code></pre>
  
  <p>I use <strong>TestRestTemplate</strong> in a test like so: </p>
  
  <pre><code>ResponseEntity&lt;List&lt;LessonDto&gt;&gt; lessonDtos =
          testRestTemplate.exchange("/lessons", HttpMethod.GET, null,
              new ParameterizedTypeReference&lt;List&lt;LessonDto&gt;&gt;() {
              });
  </code></pre>
  
  <p>This url works:</p>
  
  <pre><code>/lessons?daysOfWeek=THURSDAY
  </code></pre>
  
  <p>These urls do not:</p>
  
  <pre><code>/lessons
  /lessons?daysOfWeek=SOME_INVALID_VALUE
  </code></pre>
  
  <p>...and I get the following error:</p>
  
  <blockquote>
    <p>nested exception is
    com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot
    deserialize instance of <code>java.util.ArrayList</code> out of START_OBJECT
    token</p>
  </blockquote>
  
  <p>Any help appreciated.</p>