title: In Python's FastAPI autogenerated OpenAPI/Swagger documentation page, how can I add more error http status codes?
body: <p>FastAPI generates automatic swagger/openapi documentation.</p>
  <p>In the tutorial at <a href="https://fastapi.tiangolo.com/tutorial/response-status-code" rel="noreferrer">https://fastapi.tiangolo.com/tutorial/response-status-code</a> there's an example</p>
  <pre><code>from fastapi import FastAPI
  app = FastAPI()
  
  @app.post(&quot;/items/&quot;, status_code=201)
  async def create_item(name: str):
      return {&quot;name&quot;: name}
  </code></pre>
  <p>If you run this, the .../docs page shows two http response options:</p>
  <p>Status Code 201 for success and Status Code 422 for Validation error</p>
  <p>The above tutorial shows a picture of this page<a href="https://i.stack.imgur.com/mA6nY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mA6nY.png" alt="FastAPI docs" /></a>)</p>
  <p>I would like to document more responde status_code descriptions in the docs, for example
  code 403, &quot;Forbidden&quot;</p>
  <p>While I can run exceptions like this in code</p>
  <pre><code>raise HTTPException(status_code=403, detail=&quot;Forbidden&quot;)
  </code></pre>
  <p>I have not found a way to describe them in the autogenerated docs.</p>
  <p>Any idea how to do that?</p>