title: How to preview API JSON response in swagger when using content-disposition: attachment; filename="api.json"
body: <p>I am using Java, Swagger 2.</p>
  <p>I need to use <code>content-disposition: attachment; filename=&quot;file.json&quot;</code> in the response header of the APIs but when I use this header, I see the Download file button link and the file includes the response. When I use the APIs in UI(React) or any other rest API client, I get JSON response rather than download file link which is expected.</p>
  <p><a href="https://i.stack.imgur.com/pZClV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pZClV.png" alt="enter image description here" /></a></p>
  <p>This is how I am setting header in CORS filter.</p>
  <pre><code>private void setHeaders(HttpServletResponse response, HttpServletRequest request){
      response.setHeader(&quot;Content-Disposition&quot;, &quot;attachment; filename=\&quot;file.json\&quot;&quot;);
    }
  </code></pre>
  <p>Setting <code>application/json</code></p>
  <pre><code>@GetMapping(path=&quot;/xyz&quot;, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  </code></pre>
  <p>I want swagger also to preview the response JSON rather than showing up the Download link button.</p>