Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit526bac2

Browse files
Merge branch 'master' into translation-uk/testing
2 parentsafc3db6 +8c9c536 commit526bac2

File tree

72 files changed

+850
-2919
lines changed

Some content is hidden

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

72 files changed

+850
-2919
lines changed

‎.github/workflows/deploy-docs.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
BRANCH:${{ ( github.event.workflow_run.head_repository.full_name == github.repository && github.event.workflow_run.head_branch == 'master' && 'main' ) || ( github.event.workflow_run.head_sha ) }}
6565
# TODO: Use v3 when it's fixed, probably in v3.11
6666
# https://github.com/cloudflare/wrangler-action/issues/307
67-
uses:cloudflare/wrangler-action@v3.13
67+
uses:cloudflare/wrangler-action@v3.14
6868
# uses: cloudflare/wrangler-action@v3
6969
with:
7070
apiToken:${{ secrets.CLOUDFLARE_API_TOKEN }}

‎docs/de/docs/tutorial/query-params-str-validations.md‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -315,22 +315,6 @@ Wenn Sie einen Parameter erforderlich machen wollen, während Sie `Query` verwen
315315

316316
{* ../../docs_src/query_params_str_validations/tutorial006_an_py39.py hl[9]*}
317317

318-
###Erforderlich mit Ellipse (`...`)
319-
320-
Es gibt eine Alternative, die explizit deklariert, dass ein Wert erforderlich ist. Sie können als Default das <abbrtitle='Zeichenfolge, die einen Wert direkt darstellt, etwa 1, "hallowelt", True, None'>Literal</abbr>`...` setzen:
321-
322-
{* ../../docs_src/query_params_str_validations/tutorial006b_an_py39.py hl[9]*}
323-
324-
/// info
325-
326-
Falls Sie das`...` bisher noch nicht gesehen haben: Es ist ein spezieller einzelner Wert, <ahref="https://docs.python.org/3/library/constants.html#Ellipsis"class="external-link"target="_blank">Teil von Python und wird „Ellipsis“ genannt</a> (Deutsch: Ellipse).
327-
328-
Es wird von Pydantic und FastAPI verwendet, um explizit zu deklarieren, dass ein Wert erforderlich ist.
329-
330-
///
331-
332-
Dies wird**FastAPI** wissen lassen, dass dieser Parameter erforderlich ist.
333-
334318
###Erforderlich, kann`None` sein
335319

336320
Sie können deklarieren, dass ein Parameter`None` akzeptiert, aber dennoch erforderlich ist. Das zwingt Clients, den Wert zu senden, selbst wenn er`None` ist.

‎docs/em/docs/tutorial/query-params-str-validations.md‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -148,22 +148,6 @@ q: Union[str, None] = Query(default=None, min_length=3)
148148

149149
{* ../../docs_src/query_params_str_validations/tutorial006.py hl[7]*}
150150

151-
###✔ ⏮️ ❕ (`...`)
152-
153-
📤 🎛 🌌 🎯 📣 👈 💲 ✔. 👆 💪 ⚒`default` 🔢 🔑 💲`...`:
154-
155-
{* ../../docs_src/query_params_str_validations/tutorial006b.py hl[7]*}
156-
157-
/// info
158-
159-
🚥 👆 🚫 👀 👈`...` ⏭: ⚫️ 🎁 👁 💲, ⚫️ <ahref="https://docs.python.org/3/library/constants.html#Ellipsis"class="external-link"target="_blank">🍕 🐍&amp; 🤙 "❕"</a>.
160-
161-
⚫️ ⚙️ Pydantic&amp; FastAPI 🎯 📣 👈 💲 ✔.
162-
163-
///
164-
165-
👉 🔜 ➡️**FastAPI** 💭 👈 👉 🔢 ✔.
166-
167151
###✔ ⏮️`None`
168152

169153
👆 💪 📣 👈 🔢 💪 🚫`None`, ✋️ 👈 ⚫️ ✔. 👉 🔜 ⚡ 👩‍💻 📨 💲, 🚥 💲`None`.
@@ -178,18 +162,6 @@ Pydantic, ❔ ⚫️❔ 🏋️ 🌐 💽 🔬 &amp; 🛠️ FastAPI, ✔️
178162

179163
///
180164

181-
###⚙️ Pydantic`Required` ↩️ ❕ (`...`)
182-
183-
🚥 👆 💭 😬 ⚙️`...`, 👆 💪 🗄&amp; ⚙️`Required` ⚪️➡️ Pydantic:
184-
185-
{* ../../docs_src/query_params_str_validations/tutorial006d.py hl[2,8]*}
186-
187-
/// tip
188-
189-
💭 👈 🌅 💼, 🕐❔ 🕳 🚚, 👆 💪 🎯 🚫`default` 🔢, 👆 🛎 🚫 ✔️ ⚙️`...` 🚫`Required`.
190-
191-
///
192-
193165
##🔢 🔢 📇 / 💗 💲
194166

195167
🕐❔ 👆 🔬 🔢 🔢 🎯 ⏮️`Query` 👆 💪 📣 ⚫️ 📨 📇 💲, ⚖️ 🙆‍♀ 🎏 🌌, 📨 💗 💲.

‎docs/en/data/members.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ members:
1717
-login:patrick91
1818
avatar_url:https://avatars.githubusercontent.com/u/667029
1919
url:https://github.com/patrick91
20+
-login:luzzodev
21+
avatar_url:https://avatars.githubusercontent.com/u/27291415
22+
url:https://github.com/luzzodev

‎docs/en/data/sponsors.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,6 @@ bronze:
5858
-url:https://testdriven.io/courses/tdd-fastapi/
5959
title:Learn to build high-quality web apps with best practices
6060
img:https://fastapi.tiangolo.com/img/sponsors/testdriven.svg
61+
-url:https://lambdatest.com/?utm_source=fastapi&utm_medium=partner&utm_campaign=sponsor&utm_term=opensource&utm_content=webpage
62+
title:LambdaTest, AI-Powered Cloud-based Test Orchestration Platform
63+
img:https://fastapi.tiangolo.com/img/sponsors/lambdatest.png
6.17 KB
Loading

‎docs/en/docs/release-notes.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,28 @@ hide:
77

88
## Latest Changes
99

10+
### Refactors
11+
12+
* ✅ Simplify tests for `query_params_str_validations`. PR [#13218](https://github.com/fastapi/fastapi/pull/13218) by [@alv2017](https://github.com/alv2017).
13+
* ✅ Simplify tests for `app_testing`. PR [#13220](https://github.com/fastapi/fastapi/pull/13220) by [@alv2017](https://github.com/alv2017).
14+
* ✅ Simplify tests for `dependency_testing`. PR [#13223](https://github.com/fastapi/fastapi/pull/13223) by [@alv2017](https://github.com/alv2017).
15+
1016
### Docs
1117

18+
* 🐛 Fix issue with Swagger theme change example in the official tutorial. PR [#13289](https://github.com/fastapi/fastapi/pull/13289) by [@Zerohertz](https://github.com/Zerohertz).
19+
* 📝 Add more precise description of HTTP status code range in docs. PR [#13347](https://github.com/fastapi/fastapi/pull/13347) by [@DanielYang59](https://github.com/DanielYang59).
20+
* 🔥 Remove manual type annotations in JWT tutorial to avoid typing expectations (JWT doesn't provide more types). PR [#13378](https://github.com/fastapi/fastapi/pull/13378) by [@tiangolo](https://github.com/tiangolo).
21+
* 📝 Update docs for Query Params and String Validations, remove obsolete Ellipsis docs (`...`). PR [#13377](https://github.com/fastapi/fastapi/pull/13377) by [@tiangolo](https://github.com/tiangolo).
22+
* ✏️ Remove duplicate title in docs `body-multiple-params`. PR [#13345](https://github.com/fastapi/fastapi/pull/13345) by [@DanielYang59](https://github.com/DanielYang59).
1223
* 📝 Fix test badge. PR [#13313](https://github.com/fastapi/fastapi/pull/13313) by [@esadek](https://github.com/esadek).
1324

1425
### Translations
1526

27+
* 🌐 Update Korean translation for `docs/ko/docs/help-fastapi.md`. PR [#13262](https://github.com/fastapi/fastapi/pull/13262) by [@Zerohertz](https://github.com/Zerohertz).
28+
* 🌐 Add Korean translation for `docs/ko/docs/advanced/custom-response.md`. PR [#13265](https://github.com/fastapi/fastapi/pull/13265) by [@11kkw](https://github.com/11kkw).
29+
* 🌐 Update Korean translation for `docs/ko/docs/tutorial/security/simple-oauth2.md`. PR [#13335](https://github.com/fastapi/fastapi/pull/13335) by [@yes0ng](https://github.com/yes0ng).
30+
* 🌐 Add Russian translation for `docs/ru/docs/advanced/response-cookies.md`. PR [#13327](https://github.com/fastapi/fastapi/pull/13327) by [@Stepakinoyan](https://github.com/Stepakinoyan).
31+
* 🌐 Add Vietnamese translation for `docs/vi/docs/tutorial/static-files.md`. PR [#11291](https://github.com/fastapi/fastapi/pull/11291) by [@ptt3199](https://github.com/ptt3199).
1632
* 🌐 Add Korean translation for `docs/ko/docs/tutorial/dependencies/dependencies-with-yield.md`. PR [#13257](https://github.com/fastapi/fastapi/pull/13257) by [@11kkw](https://github.com/11kkw).
1733
* 🌐 Add Vietnamese translation for `docs/vi/docs/virtual-environments.md`. PR [#13282](https://github.com/fastapi/fastapi/pull/13282) by [@ptt3199](https://github.com/ptt3199).
1834
* 🌐 Add Ukrainian translation for `docs/uk/docs/tutorial/static-files.md`. PR [#13285](https://github.com/fastapi/fastapi/pull/13285) by [@valentinDruzhinin](https://github.com/valentinDruzhinin).
@@ -26,6 +42,9 @@ hide:
2642

2743
### Internal
2844

45+
* 🔧 Update team: Add Ludovico. PR [#13390](https://github.com/fastapi/fastapi/pull/13390) by [@tiangolo](https://github.com/tiangolo).
46+
* 🔧 Update sponsors: Add LambdaTest. PR [#13389](https://github.com/fastapi/fastapi/pull/13389) by [@tiangolo](https://github.com/tiangolo).
47+
* ⬆ Bump cloudflare/wrangler-action from 3.13 to 3.14. PR [#13350](https://github.com/fastapi/fastapi/pull/13350) by [@dependabot[bot]](https://github.com/apps/dependabot).
2948
* ⬆ Bump mkdocs-material from 9.5.18 to 9.6.1. PR [#13301](https://github.com/fastapi/fastapi/pull/13301) by [@dependabot[bot]](https://github.com/apps/dependabot).
3049
* ⬆ Bump pillow from 11.0.0 to 11.1.0. PR [#13300](https://github.com/fastapi/fastapi/pull/13300) by [@dependabot[bot]](https://github.com/apps/dependabot).
3150
* 👥 Update FastAPI People - Sponsors. PR [#13295](https://github.com/fastapi/fastapi/pull/13295) by [@tiangolo](https://github.com/tiangolo).

‎docs/en/docs/tutorial/body-multiple-params.md‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ And you can also declare body parameters as optional, by setting the default to
1010

1111
{* ../../docs_src/body_multiple_params/tutorial001_an_py310.py hl[18:20]*}
1212

13-
##Multiple body parameters
14-
1513
/// note
1614

1715
Notice that, in this case, the`item` that would be taken from the body is optional. As it has a`None` default value.

‎docs/en/docs/tutorial/query-params-str-validations.md‎

Lines changed: 15 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Let's take this application as example:
66

77
{* ../../docs_src/query_params_str_validations/tutorial001_py310.py hl[7]*}
88

9-
The query parameter`q` is of type`Union[str, None]` (or`str| None` in Python 3.10), that means that it's of type`str` but could also be`None`, and indeed, the default value is`None`, so FastAPI will know it's not required.
9+
The query parameter`q` is of type`str| None`, that means that it's of type`str` but could also be`None`, and indeed, the default value is`None`, so FastAPI will know it's not required.
1010

1111
/// note
1212

1313
FastAPI will know that the value of`q` is not required because of the default value`= None`.
1414

15-
The`Union` in`Union[str,None]` will allow your editor to give you better support and detect errors.
15+
Having`str |None` will allow your editor to give you better support and detect errors.
1616

1717
///
1818

@@ -25,29 +25,9 @@ We are going to enforce that even though `q` is optional, whenever it is provide
2525
To achieve that, first import:
2626

2727
*`Query` from`fastapi`
28-
*`Annotated` from`typing` (or from`typing_extensions` in Python below 3.9)
28+
*`Annotated` from`typing`
2929

30-
//// tab | Python 3.10+
31-
32-
In Python 3.9 or above,`Annotated` is part of the standard library, so you can import it from`typing`.
33-
34-
```Python hl_lines="1 3"
35-
{!> ../../docs_src/query_params_str_validations/tutorial002_an_py310.py!}
36-
```
37-
38-
////
39-
40-
//// tab | Python 3.8+
41-
42-
In versions of Python below Python 3.9 you import`Annotated` from`typing_extensions`.
43-
44-
It will already be installed with FastAPI.
45-
46-
```Python hl_lines="3-4"
47-
{!> ../../docs_src/query_params_str_validations/tutorial002_an.py!}
48-
```
49-
50-
////
30+
{* ../../docs_src/query_params_str_validations/tutorial002_an_py310.py hl[1,3]*}
5131

5232
/// info
5333

@@ -145,54 +125,23 @@ As in this case (without using `Annotated`) we have to replace the default value
145125

146126
So:
147127

148-
```Python
149-
q: Union[str,None]= Query(default=None)
150-
```
151-
152-
...makes the parameter optional, with a default value of`None`, the same as:
153-
154-
```Python
155-
q: Union[str,None]=None
156-
```
157-
158-
And in Python 3.10 and above:
159-
160128
```Python
161129
q:str|None= Query(default=None)
162130
```
163131

164132
...makes the parameter optional, with a default value of`None`, the same as:
165133

166-
```Python
167-
q:str|None=None
168-
```
169-
170-
But the`Query` versions declare it explicitly as being a query parameter.
171-
172-
/// info
173-
174-
Keep in mind that the most important part to make a parameter optional is the part:
175134

176135
```Python
177-
=None
178-
```
179-
180-
or the:
181-
182-
```Python
183-
= Query(default=None)
136+
q:str|None=None
184137
```
185138

186-
as it will use that`None` as the default value, and that way make the parameter**not required**.
187-
188-
The`Union[str, None]` part allows your editor to provide better support, but it is not what tells FastAPI that this parameter is not required.
189-
190-
///
139+
But the`Query` version declares it explicitly as being a query parameter.
191140

192141
Then, we can pass more parameters to`Query`. In this case, the`max_length` parameter that applies to strings:
193142

194143
```Python
195-
q:Union[str,None]= Query(default=None,max_length=50)
144+
q:str|None= Query(default=None,max_length=50)
196145
```
197146

198147
This will validate the data, show a clear error when the data is not valid, and document the parameter in the OpenAPI schema*path operation*.
@@ -201,7 +150,7 @@ This will validate the data, show a clear error when the data is not valid, and
201150

202151
Keep in mind that when using`Query` inside of`Annotated` you cannot use the`default` parameter for`Query`.
203152

204-
Instead use the actual default value of the function parameter. Otherwise, it would be inconsistent.
153+
Instead, use the actual default value of the function parameter. Otherwise, it would be inconsistent.
205154

206155
For example, this is not allowed:
207156

@@ -255,7 +204,7 @@ This specific regular expression pattern checks that the received parameter valu
255204

256205
If you feel lost with all these**"regular expression"** ideas, don't worry. They are a hard topic for many people. You can still do a lot of stuff without needing regular expressions yet.
257206

258-
But wheneveryouneed them and go and learnthem, know thatyou canalreadyuse them directly in**FastAPI**.
207+
Nowyouknow that whenever you needthemyou can use them in**FastAPI**.
259208

260209
###Pydantic v1`regex` instead of`pattern`
261210

@@ -296,23 +245,15 @@ q: str
296245
instead of:
297246

298247
```Python
299-
q:Union[str,None]=None
248+
q:str|None=None
300249
```
301250

302251
But we are now declaring it with`Query`, for example like:
303252

304253
//// tab | Annotated
305254

306255
```Python
307-
q: Annotated[Union[str,None], Query(min_length=3)]=None
308-
```
309-
310-
////
311-
312-
//// tab | non-Annotated
313-
314-
```Python
315-
q: Union[str,None]= Query(default=None,min_length=3)
256+
q: Annotated[str|None, Query(min_length=3)]=None
316257
```
317258

318259
////
@@ -321,42 +262,14 @@ So, when you need to declare a value as required while using `Query`, you can si
321262

322263
{* ../../docs_src/query_params_str_validations/tutorial006_an_py39.py hl[9]*}
323264

324-
###Required with Ellipsis (`...`)
325-
326-
There's an alternative way to explicitly declare that a value is required. You can set the default to the literal value`...`:
327-
328-
{* ../../docs_src/query_params_str_validations/tutorial006b_an_py39.py hl[9]*}
329-
330-
/// info
331-
332-
If you hadn't seen that`...` before: it is a special single value, it is <ahref="https://docs.python.org/3/library/constants.html#Ellipsis"class="external-link"target="_blank">part of Python and is called "Ellipsis"</a>.
333-
334-
It is used by Pydantic and FastAPI to explicitly declare that a value is required.
335-
336-
///
337-
338-
This will let**FastAPI** know that this parameter is required.
339-
340265
###Required, can be`None`
341266

342267
You can declare that a parameter can accept`None`, but that it's still required. This would force clients to send a value, even if the value is`None`.
343268

344-
To do that, you can declare that`None` is a valid type butstill use`...` as the default:
269+
To do that, you can declare that`None` is a valid type butsimply do not declare a default value:
345270

346271
{* ../../docs_src/query_params_str_validations/tutorial006c_an_py310.py hl[9]*}
347272

348-
/// tip
349-
350-
Pydantic, which is what powers all the data validation and serialization in FastAPI, has a special behavior when you use`Optional` or`Union[Something, None]` without a default value, you can read more about it in the Pydantic docs about <ahref="https://docs.pydantic.dev/2.3/usage/models/#required-optional-fields"class="external-link"target="_blank">Required fields</a>.
351-
352-
///
353-
354-
/// tip
355-
356-
Remember that in most of the cases, when something is required, you can simply omit the default, so you normally don't have to use`...`.
357-
358-
///
359-
360273
##Query parameter list / multiple values
361274

362275
When you define a query parameter explicitly with`Query` you can also declare it to receive a list of values, or said in another way, to receive multiple values.
@@ -396,7 +309,7 @@ The interactive API docs will update accordingly, to allow multiple values:
396309

397310
###Query parameter list / multiple values with defaults
398311

399-
And you can also define a default`list` of values if none are provided:
312+
You can also define a default`list` of values if none are provided:
400313

401314
{* ../../docs_src/query_params_str_validations/tutorial012_an_py39.py hl[9]*}
402315

@@ -419,15 +332,15 @@ the default of `q` will be: `["foo", "bar"]` and your response will be:
419332

420333
####Using just`list`
421334

422-
You can also use`list` directly instead of`List[str]` (or`list[str]` in Python 3.9+):
335+
You can also use`list` directly instead of`list[str]`:
423336

424337
{* ../../docs_src/query_params_str_validations/tutorial013_an_py39.py hl[9]*}
425338

426339
/// note
427340

428341
Keep in mind that in this case, FastAPI won't check the contents of the list.
429342

430-
For example,`List[int]` would check (and document) that the contents of the list are integers. But`list` alone wouldn't.
343+
For example,`list[int]` would check (and document) that the contents of the list are integers. But`list` alone wouldn't.
431344

432345
///
433346

‎docs/en/docs/tutorial/response-status-code.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ These status codes have a name associated to recognize them, but the important p
5353

5454
In short:
5555

56-
*`100` and above are for "Information". You rarely use them directly. Responses with these status codes cannot have a body.
57-
***`200`** and above are for "Successful" responses. These are the ones you would use the most.
56+
*`100 - 199` are for "Information". You rarely use them directly. Responses with these status codes cannot have a body.
57+
***`200 - 299`** are for "Successful" responses. These are the ones you would use the most.
5858
*`200` is the default status code, which means everything was "OK".
5959
* Another example would be`201`, "Created". It is commonly used after creating a new record in the database.
6060
* A special case is`204`, "No Content". This response is used when there is no content to return to the client, and so the response must not have a body.
61-
***`300`** and above are for "Redirection". Responses with these status codes may or may not have a body, except for`304`, "Not Modified", which must not have one.
62-
***`400`** and above are for "Client error" responses. These are the second type you would probably use the most.
61+
***`300 - 399`** are for "Redirection". Responses with these status codes may or may not have a body, except for`304`, "Not Modified", which must not have one.
62+
***`400 - 499`** are for "Client error" responses. These are the second type you would probably use the most.
6363
* An example is`404`, for a "Not Found" response.
6464
* For generic errors from the client, you can just use`400`.
65-
*`500` and above are for server errors. You almost never use them directly. When something goes wrong at some part in your application code, or server, it will automatically return one of these status codes.
65+
*`500 - 599` are for server errors. You almost never use them directly. When something goes wrong at some part in your application code, or server, it will automatically return one of these status codes.
6666

6767
/// tip
6868

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp