Browse Source

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

pull/12821/head
Alex Wendland 5 months ago
committed by GitHub
parent
commit
f6819ba5d2
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 128
      docs/en/docs/tutorial/path-operation-configuration.md

128
docs/en/docs/tutorial/path-operation-configuration.md

@ -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:

Loading…
Cancel
Save