title: Workaround for Sonarqube rule: ' Remove usage of generic wildcard type' in dynamic return
body: <p>Addressing a '<em>code smell</em>' on one of my endpoints where I set the body return type dynamically. The logic will return either an APPLICATION.PDF or MEDIATYPE.IMAGE_PNG. This works as-is, but was wondering if there is a more proper way</p>
  <pre><code>@GetMapping(value = &quot;/form&quot;, produces = {MediaType.APPLICATION_PDF_VALUE, MediaType.IMAGE_PNG_VALUE})
      public ResponseEntity&lt;?&gt; retrieveForm(@RequestParam String formType,
                                            @RequestParam String form,
                                            @RequestParam(required = false, defaultValue = &quot;false&quot;) boolean responseTypePng
      ) {
          byte[] formAsBytes =  manager.retrieveForm(formType, form);
  
          if(!responseTypePng) {
              return ResponseEntity.ok(formAsBytes);
          }
  
          return ResponseEntity.ok()
                  .contentType(MediaType.IMAGE_PNG)
                  .body(PDFConverterUtility.convertToPNG(formAsBytes));
      }
  </code></pre>
  <p><br/><br/></p>
  <p><a href="https://i.stack.imgur.com/wRI3D.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wRI3D.png" alt="enter image description here" /></a>
  <br/></p>