Skip to content

Commit 82a9dd4

Browse files
authored
Merge branch 'master' into add-urdu-translation-external-link-page
2 parents b84de31 + 6944ae1 commit 82a9dd4

47 files changed

Lines changed: 4747 additions & 622 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/issue-manager.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
env:
2424
GITHUB_CONTEXT: ${{ toJson(github) }}
2525
run: echo "$GITHUB_CONTEXT"
26-
- uses: tiangolo/issue-manager@0.4.0
26+
- uses: tiangolo/issue-manager@0.5.0
2727
with:
2828
token: ${{ secrets.FASTAPI_ISSUE_MANAGER }}
2929
config: >

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ The key features are:
5353
<a href="https://reflex.dev" target="_blank" title="Reflex"><img src="https://fastapi.tiangolo.com/img/sponsors/reflex.png"></a>
5454
<a href="https://github.com/scalar/scalar/?utm_source=fastapi&utm_medium=website&utm_campaign=main-badge" target="_blank" title="Scalar: Beautiful Open-Source API References from Swagger/OpenAPI files"><img src="https://fastapi.tiangolo.com/img/sponsors/scalar.svg"></a>
5555
<a href="https://www.propelauth.com/?utm_source=fastapi&utm_campaign=1223&utm_medium=mainbadge" target="_blank" title="Auth, user management and more for your B2B product"><img src="https://fastapi.tiangolo.com/img/sponsors/propelauth.png"></a>
56-
<a href="https://www.deta.sh/?ref=fastapi" target="_blank" title="The launchpad for all your (team's) ideas"><img src="https://fastapi.tiangolo.com/img/sponsors/deta.svg"></a>
57-
<a href="https://training.talkpython.fm/fastapi-courses" target="_blank" title="FastAPI video courses on demand from people you trust"><img src="https://fastapi.tiangolo.com/img/sponsors/talkpython.png"></a>
56+
<a href="https://www.withcoherence.com/?utm_medium=advertising&utm_source=fastapi&utm_campaign=banner%20january%2024" target="_blank" title="Coherence"><img src="https://fastapi.tiangolo.com/img/sponsors/coherence.png"></a>
57+
<a href="https://training.talkpython.fm/fastapi-courses" target="_blank" title="FastAPI video courses on demand from people you trust"><img src="https://fastapi.tiangolo.com/img/sponsors/talkpython-v2.jpg"></a>
5858
<a href="https://testdriven.io/courses/tdd-fastapi/" target="_blank" title="Learn to build high-quality web apps with best practices"><img src="https://fastapi.tiangolo.com/img/sponsors/testdriven.svg"></a>
5959
<a href="https://github.com/deepset-ai/haystack/" target="_blank" title="Build powerful search from composable, open source building blocks"><img src="https://fastapi.tiangolo.com/img/sponsors/haystack-fastapi.svg"></a>
6060
<a href="https://careers.powens.com/" target="_blank" title="Powens is hiring!"><img src="https://fastapi.tiangolo.com/img/sponsors/powens.png"></a>

docs/az/docs/index.md

Lines changed: 469 additions & 0 deletions
Large diffs are not rendered by default.

docs/az/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
INHERIT: ../en/mkdocs.yml
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Body – Felder
2+
3+
So wie Sie zusätzliche Validation und Metadaten in Parametern der **Pfadoperation-Funktion** mittels `Query`, `Path` und `Body` deklarieren, können Sie auch innerhalb von Pydantic-Modellen zusätzliche Validation und Metadaten deklarieren, mittels Pydantics `Field`.
4+
5+
## `Field` importieren
6+
7+
Importieren Sie es zuerst:
8+
9+
=== "Python 3.10+"
10+
11+
```Python hl_lines="4"
12+
{!> ../../../docs_src/body_fields/tutorial001_an_py310.py!}
13+
```
14+
15+
=== "Python 3.9+"
16+
17+
```Python hl_lines="4"
18+
{!> ../../../docs_src/body_fields/tutorial001_an_py39.py!}
19+
```
20+
21+
=== "Python 3.8+"
22+
23+
```Python hl_lines="4"
24+
{!> ../../../docs_src/body_fields/tutorial001_an.py!}
25+
```
26+
27+
=== "Python 3.10+ nicht annotiert"
28+
29+
!!! tip "Tipp"
30+
Bevorzugen Sie die `Annotated`-Version, falls möglich.
31+
32+
```Python hl_lines="2"
33+
{!> ../../../docs_src/body_fields/tutorial001_py310.py!}
34+
```
35+
36+
=== "Python 3.8+ nicht annotiert"
37+
38+
!!! tip "Tipp"
39+
Bevorzugen Sie die `Annotated`-Version, falls möglich.
40+
41+
```Python hl_lines="4"
42+
{!> ../../../docs_src/body_fields/tutorial001.py!}
43+
```
44+
45+
!!! warning "Achtung"
46+
Beachten Sie, dass `Field` direkt von `pydantic` importiert wird, nicht von `fastapi`, wie die anderen (`Query`, `Path`, `Body`, usw.)
47+
48+
## Modellattribute deklarieren
49+
50+
Dann können Sie `Field` mit Modellattributen deklarieren:
51+
52+
=== "Python 3.10+"
53+
54+
```Python hl_lines="11-14"
55+
{!> ../../../docs_src/body_fields/tutorial001_an_py310.py!}
56+
```
57+
58+
=== "Python 3.9+"
59+
60+
```Python hl_lines="11-14"
61+
{!> ../../../docs_src/body_fields/tutorial001_an_py39.py!}
62+
```
63+
64+
=== "Python 3.8+"
65+
66+
```Python hl_lines="12-15"
67+
{!> ../../../docs_src/body_fields/tutorial001_an.py!}
68+
```
69+
70+
=== "Python 3.10+ nicht annotiert"
71+
72+
!!! tip "Tipp"
73+
Bevorzugen Sie die `Annotated`-Version, falls möglich.
74+
75+
```Python hl_lines="9-12"
76+
{!> ../../../docs_src/body_fields/tutorial001_py310.py!}
77+
```
78+
79+
=== "Python 3.8+ nicht annotiert"
80+
81+
!!! tip "Tipp"
82+
Bevorzugen Sie die `Annotated`-Version, falls möglich.
83+
84+
```Python hl_lines="11-14"
85+
{!> ../../../docs_src/body_fields/tutorial001.py!}
86+
```
87+
88+
`Field` funktioniert genauso wie `Query`, `Path` und `Body`, es hat die gleichen Parameter, usw.
89+
90+
!!! note "Technische Details"
91+
Tatsächlich erstellen `Query`, `Path` und andere, die sie kennenlernen werden, Instanzen von Unterklassen einer allgemeinen Klasse `Param`, die ihrerseits eine Unterklasse von Pydantics `FieldInfo`-Klasse ist.
92+
93+
Und Pydantics `Field` gibt ebenfalls eine Instanz von `FieldInfo` zurück.
94+
95+
`Body` gibt auch Instanzen einer Unterklasse von `FieldInfo` zurück. Und später werden Sie andere sehen, die Unterklassen der `Body`-Klasse sind.
96+
97+
Denken Sie daran, dass `Query`, `Path` und andere von `fastapi` tatsächlich Funktionen sind, die spezielle Klassen zurückgeben.
98+
99+
!!! tip "Tipp"
100+
Beachten Sie, dass jedes Modellattribut mit einem Typ, Defaultwert und `Field` die gleiche Struktur hat wie ein Parameter einer Pfadoperation-Funktion, nur mit `Field` statt `Path`, `Query`, `Body`.
101+
102+
## Zusätzliche Information hinzufügen
103+
104+
Sie können zusätzliche Information in `Field`, `Query`, `Body`, usw. deklarieren. Und es wird im generierten JSON-Schema untergebracht.
105+
106+
Sie werden später mehr darüber lernen, wie man zusätzliche Information unterbringt, wenn Sie lernen, Beispiele zu deklarieren.
107+
108+
!!! warning "Achtung"
109+
Extra-Schlüssel, die `Field` überreicht werden, werden auch im resultierenden OpenAPI-Schema Ihrer Anwendung gelistet. Da diese Schlüssel nicht notwendigerweise Teil der OpenAPI-Spezifikation sind, könnten einige OpenAPI-Tools, wie etwa [der OpenAPI-Validator](https://validator.swagger.io/), nicht mit Ihrem generierten Schema funktionieren.
110+
111+
## Zusammenfassung
112+
113+
Sie können Pydantics `Field` verwenden, um zusätzliche Validierungen und Metadaten für Modellattribute zu deklarieren.
114+
115+
Sie können auch Extra-Schlüssel verwenden, um zusätzliche JSON-Schema-Metadaten zu überreichen.

0 commit comments

Comments
 (0)