Browse Source

📝 Update includes in `docs/en/docs/advanced/path-operation-advanced-configuration.md` (#12802)

pull/12810/head
Zhaohan Dong 5 months ago
committed by GitHub
parent
commit
b5036db18c
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 40
      docs/en/docs/advanced/path-operation-advanced-configuration.md

40
docs/en/docs/advanced/path-operation-advanced-configuration.md

@ -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. 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 hl[6] *}
{!../../docs_src/path_operation_advanced_configuration/tutorial001.py!}
```
### Using the *path operation function* name as the operationId ### 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*. 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 hl[2, 12:21, 24] *}
{!../../docs_src/path_operation_advanced_configuration/tutorial002.py!}
```
/// tip /// 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`: 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 hl[6] *}
{!../../docs_src/path_operation_advanced_configuration/tutorial003.py!}
```
## Advanced description from docstring ## 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. 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 hl[19:29] *}
{!../../docs_src/path_operation_advanced_configuration/tutorial004.py!}
```
## Additional Responses ## 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): 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 hl[6] *}
{!../../docs_src/path_operation_advanced_configuration/tutorial005.py!}
```
If you open the automatic API docs, your extension will show up at the bottom of the specific *path operation*. 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`: You could do that with `openapi_extra`:
```Python hl_lines="19-36 39-40" {* ../../docs_src/path_operation_advanced_configuration/tutorial006.py hl[19:36, 39:40] *}
{!../../docs_src/path_operation_advanced_configuration/tutorial006.py!}
```
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. 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 //// tab | Pydantic v2
```Python hl_lines="17-22 24" {* ../../docs_src/path_operation_advanced_configuration/tutorial007.py hl[17:22, 24] *}
{!> ../../docs_src/path_operation_advanced_configuration/tutorial007.py!}
```
//// ////
//// tab | Pydantic v1 //// tab | Pydantic v1
```Python hl_lines="17-22 24" {* ../../docs_src/path_operation_advanced_configuration/tutorial007_pv1.py hl[17:22, 24] *}
{!> ../../docs_src/path_operation_advanced_configuration/tutorial007_pv1.py!}
```
//// ////
@ -195,17 +179,13 @@ And then in our code, we parse that YAML content directly, and then we are again
//// tab | Pydantic v2 //// tab | Pydantic v2
```Python hl_lines="26-33" {* ../../docs_src/path_operation_advanced_configuration/tutorial007.py hl[26:33] *}
{!> ../../docs_src/path_operation_advanced_configuration/tutorial007.py!}
```
//// ////
//// tab | Pydantic v1 //// tab | Pydantic v1
```Python hl_lines="26-33" {* ../../docs_src/path_operation_advanced_configuration/tutorial007_pv1.py hl[26:33] *}
{!> ../../docs_src/path_operation_advanced_configuration/tutorial007_pv1.py!}
```
//// ////

Loading…
Cancel
Save