title: How to return status code in response correctly?
body: <p>So I am learning FastAPI and I am trying to figure out how to return the status code correctly.
  I made an endpoint for uploading a file and I want to make a special response in case the file format is unsupported. It seems like I did everything according to the <a href="https://fastapi.tiangolo.com/advanced/response-change-status-code/" rel="nofollow noreferrer">official documentation</a>, but I am always getting <code>422 Unprocessable Entity</code> error.</p>
  <p>Here's my code:</p>
  <pre class="lang-py prettyprint-override"><code>from fastapi import FastAPI, File, UploadFile, status
  from fastapi.openapi.models import Response
      
  app = FastAPI()
      
  @app.post('/upload_file/', status_code=status.HTTP_200_OK)
  async def upload_file(response: Response, file: UploadFile = File(...)):
      &quot;&quot;&quot;End point for uploading a file&quot;&quot;&quot;
      if file.content_type != &quot;application/pdf&quot;:
          response.status_code = status.HTTP_415_UNSUPPORTED_MEDIA_TYPE
          return {f'File {file.filename} has unsupported extension type'}
  
      return {'filename': file.content_type}
  </code></pre>
  <p>Thank you in advance!</p>