]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
📝 Update includes in `docs/en/docs/tutorial/path-operation-configuration.md` (#12809)
authorAlex Wendland <a.p.wendland@gmail.com>
Sat, 9 Nov 2024 14:54:23 +0000 (14:54 +0000)
committerGitHub <noreply@github.com>
Sat, 9 Nov 2024 14:54:23 +0000 (14:54 +0000)
docs/en/docs/tutorial/path-operation-configuration.md

index 4ca6ebf1334bdc29e967ba9b71bba5f65d8bff5a..c78d20ea6310cdbcd5e8578ab0fcccd6c44ec743 100644 (file)
@@ -16,29 +16,7 @@ You can pass directly the `int` code, like `404`.
 
 But if you don't remember what each number code is for, you can use the shortcut constants in `status`:
 
-//// tab | Python 3.10+
-
-```Python hl_lines="1  15"
-{!> ../../docs_src/path_operation_configuration/tutorial001_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="3  17"
-{!> ../../docs_src/path_operation_configuration/tutorial001_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="3  17"
-{!> ../../docs_src/path_operation_configuration/tutorial001.py!}
-```
-
-////
+{* ../../docs_src/path_operation_configuration/tutorial001_py310.py hl[1,15] *}
 
 That status code will be used in the response and will be added to the OpenAPI schema.
 
@@ -54,29 +32,7 @@ You could also use `from starlette import status`.
 
 You can add tags to your *path operation*, pass the parameter `tags` with a `list` of `str` (commonly just one `str`):
 
-//// tab | Python 3.10+
-
-```Python hl_lines="15  20  25"
-{!> ../../docs_src/path_operation_configuration/tutorial002_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="17  22  27"
-{!> ../../docs_src/path_operation_configuration/tutorial002_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="17  22  27"
-{!> ../../docs_src/path_operation_configuration/tutorial002.py!}
-```
-
-////
+{* ../../docs_src/path_operation_configuration/tutorial002_py310.py hl[15,20,25] *}
 
 They will be added to the OpenAPI schema and used by the automatic documentation interfaces:
 
@@ -90,37 +46,13 @@ In these cases, it could make sense to store the tags in an `Enum`.
 
 **FastAPI** supports that the same way as with plain strings:
 
-```Python hl_lines="1  8-10  13  18"
-{!../../docs_src/path_operation_configuration/tutorial002b.py!}
-```
+{* ../../docs_src/path_operation_configuration/tutorial002b.py hl[1,8:10,13,18] *}
 
 ## Summary and description
 
 You can add a `summary` and `description`:
 
-//// tab | Python 3.10+
-
-```Python hl_lines="18-19"
-{!> ../../docs_src/path_operation_configuration/tutorial003_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="20-21"
-{!> ../../docs_src/path_operation_configuration/tutorial003_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="20-21"
-{!> ../../docs_src/path_operation_configuration/tutorial003.py!}
-```
-
-////
+{* ../../docs_src/path_operation_configuration/tutorial003_py310.py hl[18:19] *}
 
 ## Description from docstring
 
@@ -128,29 +60,7 @@ As descriptions tend to be long and cover multiple lines, you can declare the *p
 
 You can write <a href="https://en.wikipedia.org/wiki/Markdown" class="external-link" target="_blank">Markdown</a> in the docstring, it will be interpreted and displayed correctly (taking into account docstring indentation).
 
-//// tab | Python 3.10+
-
-```Python hl_lines="17-25"
-{!> ../../docs_src/path_operation_configuration/tutorial004_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="19-27"
-{!> ../../docs_src/path_operation_configuration/tutorial004_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="19-27"
-{!> ../../docs_src/path_operation_configuration/tutorial004.py!}
-```
-
-////
+{* ../../docs_src/path_operation_configuration/tutorial004_py310.py hl[17:25] *}
 
 It will be used in the interactive docs:
 
@@ -160,29 +70,7 @@ It will be used in the interactive docs:
 
 You can specify the response description with the parameter `response_description`:
 
-//// tab | Python 3.10+
-
-```Python hl_lines="19"
-{!> ../../docs_src/path_operation_configuration/tutorial005_py310.py!}
-```
-
-////
-
-//// tab | Python 3.9+
-
-```Python hl_lines="21"
-{!> ../../docs_src/path_operation_configuration/tutorial005_py39.py!}
-```
-
-////
-
-//// tab | Python 3.8+
-
-```Python hl_lines="21"
-{!> ../../docs_src/path_operation_configuration/tutorial005.py!}
-```
-
-////
+{* ../../docs_src/path_operation_configuration/tutorial005_py310.py hl[19] *}
 
 /// info
 
@@ -204,9 +92,7 @@ So, if you don't provide one, **FastAPI** will automatically generate one of "Su
 
 If you need to mark a *path operation* as <abbr title="obsolete, recommended not to use it">deprecated</abbr>, but without removing it, pass the parameter `deprecated`:
 
-```Python hl_lines="16"
-{!../../docs_src/path_operation_configuration/tutorial006.py!}
-```
+{* ../../docs_src/path_operation_configuration/tutorial006.py hl[16] *}
 
 It will be clearly marked as deprecated in the interactive docs: