First, you need to import `BaseModel` from `pydantic`:
-//// tab | Python 3.10+
-
-```Python hl_lines="2"
-{!> ../../docs_src/body/tutorial001_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="4"
-{!> ../../docs_src/body/tutorial001.py!}
-```
-
-////
+{* ../../docs_src/body/tutorial001_py310.py hl[2] *}
## Create your data model
Use standard Python types for all the attributes:
-//// tab | Python 3.10+
-
-```Python hl_lines="5-9"
-{!> ../../docs_src/body/tutorial001_py310.py!}
-```
-
-////
+{* ../../docs_src/body/tutorial001_py310.py hl[5:9] *}
-//// tab | Python 3.8+
-
-```Python hl_lines="7-11"
-{!> ../../docs_src/body/tutorial001.py!}
-```
-
-////
The same as when declaring query parameters, when a model attribute has a default value, it is not required. Otherwise, it is required. Use `None` to make it just optional.
To add it to your *path operation*, declare it the same way you declared path and query parameters:
-//// tab | Python 3.10+
-
-```Python hl_lines="16"
-{!> ../../docs_src/body/tutorial001_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="18"
-{!> ../../docs_src/body/tutorial001.py!}
-```
-
-////
+{* ../../docs_src/body/tutorial001_py310.py hl[16] *}
...and declare its type as the model you created, `Item`.
Inside of the function, you can access all the attributes of the model object directly:
-//// tab | Python 3.10+
-
-```Python hl_lines="19"
{!> ../../docs_src/body/tutorial002_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="21"
-{!> ../../docs_src/body/tutorial002.py!}
-```
-
-////
## Request body + path parameters
**FastAPI** will recognize that the function parameters that match path parameters should be **taken from the path**, and that function parameters that are declared to be Pydantic models should be **taken from the request body**.
-//// tab | Python 3.10+
-
-```Python hl_lines="15-16"
-{!> ../../docs_src/body/tutorial003_py310.py!}
-```
-
-////
+{* ../../docs_src/body/tutorial003_py310.py hl[15:16] *}
-//// tab | Python 3.8+
-
-```Python hl_lines="17-18"
-{!> ../../docs_src/body/tutorial003.py!}
-```
-
-////
## Request body + path + query parameters
**FastAPI** will recognize each of them and take the data from the correct place.
-//// tab | Python 3.10+
-
-```Python hl_lines="16"
-{!> ../../docs_src/body/tutorial004_py310.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="18"
-{!> ../../docs_src/body/tutorial004.py!}
-```
-
-////
+{* ../../docs_src/body/tutorial004_py310.py hl[16] *}
The function parameters will be recognized as follows: