mirror of https://github.com/tiangolo/fastapi.git
📝 Improve explanation of request bodies
This commit is contained in:
parent
098e629344
commit
dd2541bc97
|
|
@ -36,7 +36,7 @@ The key features are:
|
||||||
* **Easy**: Designed to be easy to use and learn. Less time reading docs.
|
* **Easy**: Designed to be easy to use and learn. Less time reading docs.
|
||||||
* **Short**: Minimize code duplication. Multiple features from each parameter declaration. Less bugs.
|
* **Short**: Minimize code duplication. Multiple features from each parameter declaration. Less bugs.
|
||||||
* **Robust**: Get production-ready code. With automatic interactive documentation.
|
* **Robust**: Get production-ready code. With automatic interactive documentation.
|
||||||
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <a href="https://github.com/OAI/OpenAPI-Specification" target="_blank">OpenAPI</a> and <a href="http://json-schema.org/" target="_blank">JSON Schema</a>.
|
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <a href="https://github.com/OAI/OpenAPI-Specification" target="_blank">OpenAPI</a> (previously known as Swagger) and <a href="http://json-schema.org/" target="_blank">JSON Schema</a>.
|
||||||
|
|
||||||
<small>* estimation based on tests on an internal development team, building production applications.</small>
|
<small>* estimation based on tests on an internal development team, building production applications.</small>
|
||||||
|
|
||||||
|
|
@ -366,7 +366,7 @@ Used by FastAPI / Starlette:
|
||||||
|
|
||||||
* <a href="http://www.uvicorn.org" target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
|
* <a href="http://www.uvicorn.org" target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
|
||||||
|
|
||||||
You can install all of these with `pip3 install fastapi[full]`.
|
You can install all of these with `pip3 install fastapi[all]`.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -366,7 +366,7 @@ Used by FastAPI / Starlette:
|
||||||
|
|
||||||
* <a href="http://www.uvicorn.org" target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
|
* <a href="http://www.uvicorn.org" target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
|
||||||
|
|
||||||
You can install all of these with `pip3 install fastapi[full]`.
|
You can install all of these with `pip3 install fastapi[all]`.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,15 @@
|
||||||
To declare a request body, you use <a href="https://pydantic-docs.helpmanual.io/" target="_blank">Pydantic</a> models with all their power and benefits.
|
When you need to send data from a client (let's say, a browser) to your API, you send it as a **request body**.
|
||||||
|
|
||||||
|
A **request** body is data sent by the client to your API. A **response** body is the data your API sends to the client.
|
||||||
|
|
||||||
|
Your API almost always has to send a **response** body. But clients don't necessarily need to send **request** bodies all the time.
|
||||||
|
|
||||||
|
To declare a **request** body, you use <a href="https://pydantic-docs.helpmanual.io/" target="_blank">Pydantic</a> models with all their power and benefits.
|
||||||
|
|
||||||
|
!!! info
|
||||||
|
You cannot send a request body using a `GET` operation (HTTP method).
|
||||||
|
|
||||||
|
To send data, you have to use one of: `POST` (the more common), `PUT`, `DELETE` or `PATCH`.
|
||||||
|
|
||||||
## Import Pydantic's `BaseModel`
|
## Import Pydantic's `BaseModel`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,13 @@ pip install fastapi[all]
|
||||||
|
|
||||||
This is what you would probably do once you want to deploy your application to production:
|
This is what you would probably do once you want to deploy your application to production:
|
||||||
|
|
||||||
```bash
|
```
|
||||||
pip install fastapi
|
pip install fastapi
|
||||||
```
|
```
|
||||||
|
|
||||||
Also install `uvicorn` to work as the server:
|
Also install `uvicorn` to work as the server:
|
||||||
|
|
||||||
```bash
|
```
|
||||||
pip install uvicorn
|
pip install uvicorn
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue