mirror of
https://github.com/fastapi/fastapi.git
synced 2026-04-12 02:51:27 -04:00
✨ Generate correct OpenAPI docs for responses with no content (#621)
This commit is contained in:
committed by
Sebastián Ramírez
parent
c5f5e63810
commit
c7902dd23a
@@ -22,6 +22,10 @@ It will:
|
||||
|
||||
<img src="/img/tutorial/response-status-code/image01.png">
|
||||
|
||||
!!! note
|
||||
Some response codes (see the next section) indicate that the response does not have a body.
|
||||
|
||||
FastAPI knows this, and will produce OpenAPI docs that state there is no response body.
|
||||
|
||||
## About HTTP status codes
|
||||
|
||||
@@ -34,11 +38,12 @@ These status codes have a name associated to recognize them, but the important p
|
||||
|
||||
In short:
|
||||
|
||||
* `100` and above are for "Information". You rarely use them directly.
|
||||
* `100` and above are for "Information". You rarely use them directly. Responses with these status codes cannot have a body.
|
||||
* **`200`** and above are for "Successful" responses. These are the ones you would use the most.
|
||||
* `200` is the default status code, which means everything was "OK".
|
||||
* Another example would be `201`, "Created". It is commonly used after creating a new record in the database.
|
||||
* `300` and above are for "Redirection".
|
||||
* A special case is `204`, "No Content". This response is used when there is no content to return to the client, and so the response must not have a body.
|
||||
* **`300`** and above are for "Redirection". Responses with these status codes may or may not have a body, except for `304`, "Not Modified", which must not have one.
|
||||
* **`400`** and above are for "Client error" responses. These are the second type you would probably use the most.
|
||||
* An example is `404`, for a "Not Found" response.
|
||||
* For generic errors from the client, you can just use `400`.
|
||||
|
||||
Reference in New Issue
Block a user