]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
📝 Update includes in `docs/en/docs/tutorial/header-param-models.md` (#12814)
authorZhaohan Dong <65422392+zhaohan-dong@users.noreply.github.com>
Sun, 10 Nov 2024 17:19:19 +0000 (17:19 +0000)
committerGitHub <noreply@github.com>
Sun, 10 Nov 2024 17:19:19 +0000 (17:19 +0000)
Signed-off-by: Zhaohan Dong <65422392+zhaohan-dong@users.noreply.github.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
docs/en/docs/tutorial/header-param-models.md

index 78517e4984da74ad29f4d09b39f0c4cba0cb8753..73950a668074e7a80e523efa4c4f412996462a7c 100644 (file)
@@ -14,71 +14,7 @@ This is supported since FastAPI version `0.115.0`. 🤓
 
 Declare the **header parameters** that you need in a **Pydantic model**, and then declare the parameter as `Header`:
 
-//// tab | Python 3.10+
-
-```Python hl_lines="9-14  18"
-{!> ../../docs_src/header_param_models/tutorial001_an_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="9-14  18"
-{!> ../../docs_src/header_param_models/tutorial001_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="10-15  19"
-{!> ../../docs_src/header_param_models/tutorial001_an.py!}
-```
-
-////
-
-//// tab | Python 3.10+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="7-12  16"
-{!> ../../docs_src/header_param_models/tutorial001_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="9-14  18"
-{!> ../../docs_src/header_param_models/tutorial001_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="7-12  16"
-{!> ../../docs_src/header_param_models/tutorial001_py310.py!}
-```
-
-////
+{* ../../docs_src/header_param_models/tutorial001_an_py310.py hl[9:14,18] *}
 
 **FastAPI** will **extract** the data for **each field** from the **headers** in the request and give you the Pydantic model you defined.
 
@@ -96,71 +32,7 @@ In some special use cases (probably not very common), you might want to **restri
 
 You can use Pydantic's model configuration to `forbid` any `extra` fields:
 
-//// tab | Python 3.10+
-
-```Python hl_lines="10"
-{!> ../../docs_src/header_param_models/tutorial002_an_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="10"
-{!> ../../docs_src/header_param_models/tutorial002_an_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="11"
-{!> ../../docs_src/header_param_models/tutorial002_an.py!}
-```
-
-////
-
-//// tab | Python 3.10+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="8"
-{!> ../../docs_src/header_param_models/tutorial002_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="10"
-{!> ../../docs_src/header_param_models/tutorial002_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+ non-Annotated
-
-/// tip
-
-Prefer to use the `Annotated` version if possible.
-
-///
-
-```Python hl_lines="10"
-{!> ../../docs_src/header_param_models/tutorial002.py!}
-```
-
-////
+{* ../../docs_src/header_param_models/tutorial002_an_py310.py hl[10] *}
 
 If a client tries to send some **extra headers**, they will receive an **error** response.