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