mirror of
https://github.com/fastapi/fastapi.git
synced 2026-07-19 19:33:19 -04:00
✨ Add support for Python's http.HTTPStatus in status_code (#1534)
* Normalise IntEnums to ints for route status codes Closes #1349 * add tests for status code enum support * add docs for status code enum support * add endpoint test for enum status code * 📝 Update note about http.HTTPStatus Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
This commit is contained in:
@@ -17,6 +17,9 @@ The same way you can specify a response model, you can also declare the HTTP sta
|
||||
|
||||
The `status_code` parameter receives a number with the HTTP status code.
|
||||
|
||||
!!! info
|
||||
`status_code` can alternatively also receive an `IntEnum`, such as Python's <a href="https://docs.python.org/3/library/http.html#http.HTTPStatus" class="external-link" target="_blank">`http.HTTPStatus`</a>.
|
||||
|
||||
It will:
|
||||
|
||||
* Return that status code in the response.
|
||||
|
||||
Reference in New Issue
Block a user