]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
📝 Update includes in `docs/en/docs/advanced/path-operation-advanced-configuration...
authorZhaohan Dong <65422392+zhaohan-dong@users.noreply.github.com>
Sat, 9 Nov 2024 11:58:07 +0000 (11:58 +0000)
committerGitHub <noreply@github.com>
Sat, 9 Nov 2024 11:58:07 +0000 (11:58 +0000)
docs/en/docs/advanced/path-operation-advanced-configuration.md

index a61e3f19b5ba363b9ab103f04c22067ce44a8ae6..fea1e4db0cbee7b77d9778dbf47f88e93ae35e50 100644 (file)
@@ -12,9 +12,7 @@ You can set the OpenAPI `operationId` to be used in your *path operation* with t
 
 You would have to make sure that it is unique for each operation.
 
-```Python hl_lines="6"
-{!../../docs_src/path_operation_advanced_configuration/tutorial001.py!}
-```
+{* ../../docs_src/path_operation_advanced_configuration/tutorial001.py hl[6] *}
 
 ### Using the *path operation function* name as the operationId
 
@@ -22,9 +20,7 @@ If you want to use your APIs' function names as `operationId`s, you can iterate
 
 You should do it after adding all your *path operations*.
 
-```Python hl_lines="2  12-21  24"
-{!../../docs_src/path_operation_advanced_configuration/tutorial002.py!}
-```
+{* ../../docs_src/path_operation_advanced_configuration/tutorial002.py hl[2, 12:21, 24] *}
 
 /// tip
 
@@ -44,9 +40,7 @@ Even if they are in different modules (Python files).
 
 To exclude a *path operation* from the generated OpenAPI schema (and thus, from the automatic documentation systems), use the parameter `include_in_schema` and set it to `False`:
 
-```Python hl_lines="6"
-{!../../docs_src/path_operation_advanced_configuration/tutorial003.py!}
-```
+{* ../../docs_src/path_operation_advanced_configuration/tutorial003.py hl[6] *}
 
 ## Advanced description from docstring
 
@@ -56,9 +50,7 @@ Adding an `\f` (an escaped "form feed" character) causes **FastAPI** to truncate
 
 It won't show up in the documentation, but other tools (such as Sphinx) will be able to use the rest.
 
-```Python hl_lines="19-29"
-{!../../docs_src/path_operation_advanced_configuration/tutorial004.py!}
-```
+{* ../../docs_src/path_operation_advanced_configuration/tutorial004.py hl[19:29] *}
 
 ## Additional Responses
 
@@ -100,9 +92,7 @@ You can extend the OpenAPI schema for a *path operation* using the parameter `op
 
 This `openapi_extra` can be helpful, for example, to declare [OpenAPI Extensions](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#specificationExtensions):
 
-```Python hl_lines="6"
-{!../../docs_src/path_operation_advanced_configuration/tutorial005.py!}
-```
+{* ../../docs_src/path_operation_advanced_configuration/tutorial005.py hl[6] *}
 
 If you open the automatic API docs, your extension will show up at the bottom of the specific *path operation*.
 
@@ -149,9 +139,7 @@ For example, you could decide to read and validate the request with your own cod
 
 You could do that with `openapi_extra`:
 
-```Python hl_lines="19-36  39-40"
-{!../../docs_src/path_operation_advanced_configuration/tutorial006.py!}
-```
+{* ../../docs_src/path_operation_advanced_configuration/tutorial006.py hl[19:36, 39:40] *}
 
 In this example, we didn't declare any Pydantic model. In fact, the request body is not even <abbr title="converted from some plain format, like bytes, into Python objects">parsed</abbr> as JSON, it is read directly as `bytes`, and the function `magic_data_reader()` would be in charge of parsing it in some way.
 
@@ -167,17 +155,13 @@ For example, in this application we don't use FastAPI's integrated functionality
 
 //// tab | Pydantic v2
 
-```Python hl_lines="17-22  24"
-{!> ../../docs_src/path_operation_advanced_configuration/tutorial007.py!}
-```
+{* ../../docs_src/path_operation_advanced_configuration/tutorial007.py hl[17:22, 24] *}
 
 ////
 
 //// tab | Pydantic v1
 
-```Python hl_lines="17-22  24"
-{!> ../../docs_src/path_operation_advanced_configuration/tutorial007_pv1.py!}
-```
+{* ../../docs_src/path_operation_advanced_configuration/tutorial007_pv1.py hl[17:22, 24] *}
 
 ////
 
@@ -195,17 +179,13 @@ And then in our code, we parse that YAML content directly, and then we are again
 
 //// tab | Pydantic v2
 
-```Python hl_lines="26-33"
-{!> ../../docs_src/path_operation_advanced_configuration/tutorial007.py!}
-```
+{* ../../docs_src/path_operation_advanced_configuration/tutorial007.py hl[26:33] *}
 
 ////
 
 //// tab | Pydantic v1
 
-```Python hl_lines="26-33"
-{!> ../../docs_src/path_operation_advanced_configuration/tutorial007_pv1.py!}
-```
+{* ../../docs_src/path_operation_advanced_configuration/tutorial007_pv1.py hl[26:33] *}
 
 ////