Browse Source

📝 Update includes for `docs/en/docs/tutorial/extra-models.md` (#12638)

pull/12835/head
VISHNU V S 5 months ago
committed by GitHub
parent
commit
480ba19e9f
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 76
      docs/en/docs/tutorial/extra-models.md

76
docs/en/docs/tutorial/extra-models.md

@ -20,21 +20,8 @@ If you don't know, you will learn what a "password hash" is in the [security cha
Here's a general idea of how the models could look like with their password fields and the places where they are used:
//// tab | Python 3.10+
{* ../../docs_src/extra_models/tutorial001_py310.py hl[7,9,14,20,22,27:28,31:33,38:39] *}
```Python hl_lines="7 9 14 20 22 27-28 31-33 38-39"
{!> ../../docs_src/extra_models/tutorial001_py310.py!}
```
////
//// tab | Python 3.8+
```Python hl_lines="9 11 16 22 24 29-30 33-35 40-41"
{!> ../../docs_src/extra_models/tutorial001.py!}
```
////
/// info
@ -176,21 +163,7 @@ All the data conversion, validation, documentation, etc. will still work as norm
That way, we can declare just the differences between the models (with plaintext `password`, with `hashed_password` and without password):
//// tab | Python 3.10+
```Python hl_lines="7 13-14 17-18 21-22"
{!> ../../docs_src/extra_models/tutorial002_py310.py!}
```
////
//// tab | Python 3.8+
```Python hl_lines="9 15-16 19-20 23-24"
{!> ../../docs_src/extra_models/tutorial002.py!}
```
////
{* ../../docs_src/extra_models/tutorial002_py310.py hl[7,13:14,17:18,21:22] *}
## `Union` or `anyOf`
@ -206,21 +179,8 @@ When defining a <a href="https://docs.pydantic.dev/latest/concepts/types/#unions
///
//// tab | Python 3.10+
```Python hl_lines="1 14-15 18-20 33"
{!> ../../docs_src/extra_models/tutorial003_py310.py!}
```
////
{* ../../docs_src/extra_models/tutorial003_py310.py hl[1,14:15,18:20,33] *}
//// tab | Python 3.8+
```Python hl_lines="1 14-15 18-20 33"
{!> ../../docs_src/extra_models/tutorial003.py!}
```
////
### `Union` in Python 3.10
@ -242,21 +202,8 @@ The same way, you can declare responses of lists of objects.
For that, use the standard Python `typing.List` (or just `list` in Python 3.9 and above):
//// tab | Python 3.9+
```Python hl_lines="18"
{!> ../../docs_src/extra_models/tutorial004_py39.py!}
```
////
{* ../../docs_src/extra_models/tutorial004_py39.py hl[18] *}
//// tab | Python 3.8+
```Python hl_lines="1 20"
{!> ../../docs_src/extra_models/tutorial004.py!}
```
////
## Response with arbitrary `dict`
@ -266,21 +213,8 @@ This is useful if you don't know the valid field/attribute names (that would be
In this case, you can use `typing.Dict` (or just `dict` in Python 3.9 and above):
//// tab | Python 3.9+
```Python hl_lines="6"
{!> ../../docs_src/extra_models/tutorial005_py39.py!}
```
////
//// tab | Python 3.8+
```Python hl_lines="1 8"
{!> ../../docs_src/extra_models/tutorial005.py!}
```
{* ../../docs_src/extra_models/tutorial005_py39.py hl[6] *}
////
## Recap

Loading…
Cancel
Save