title: Serve yaml file with Spring REST endpoint
body: <p>I want to serve a .yaml file via a REST endpoint with Spring, I know that it cannot be directly displayed in a browser (just talking about Chrome here), since it doesn't support display of yaml files.
  I have included what I think is the necessary library for this purpose
  <code>compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.9.9'</code>.</p>
  
  <p>If I open the endpoint <code>/v2/api-doc</code> in the browser, it will prompt me, to download a file named exactly as the endpoint <code>/v2/api-doc</code>. It contains the correct content.</p>
  
  <p>Question: Is there a way to correctly transfer the .yaml file, so that the user will be prompted to safe myfile.yaml?</p>
  
  <pre><code>@RequestMapping(value = "/v2/api-doc", produces = "application/x-yaml")
  public ResponseEntity&lt;String&gt; produceApiDoc() throws IOException {
      byte[] fileBytes;
      try (InputStream in = getClass().getResourceAsStream("/restAPI/myfile.yaml")) {
          fileBytes = IOUtils.toByteArray(in);
      }
      if (fileBytes != null) {
          String data = new String(fileBytes, StandardCharsets.UTF_8);
          return new ResponseEntity&lt;&gt;(data, HttpStatus.OK);
      } else {
          return new ResponseEntity&lt;&gt;(HttpStatus.NOT_FOUND);
      }
  }
  </code></pre>