From c5e41001ce919d8a4e1948a8c95b17a29cbf3598 Mon Sep 17 00:00:00 2001 From: Nils Lindemann Date: Mon, 1 Apr 2024 20:19:09 +0200 Subject: [PATCH] Unsure about these --- docs/en/docs/advanced/security/oauth2-scopes.md | 2 +- docs/en/docs/tutorial/cookie-params.md | 2 +- docs/en/docs/tutorial/header-params.md | 2 +- docs/en/docs/tutorial/query-params-str-validations.md | 8 ++++---- docs/en/docs/tutorial/response-model.md | 4 ++-- docs/en/docs/tutorial/security/oauth2-jwt.md | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/en/docs/advanced/security/oauth2-scopes.md b/docs/en/docs/advanced/security/oauth2-scopes.md index b93d2991c..b7f4bcb2d 100644 --- a/docs/en/docs/advanced/security/oauth2-scopes.md +++ b/docs/en/docs/advanced/security/oauth2-scopes.md @@ -543,7 +543,7 @@ Here's how the hierarchy of dependencies and scopes looks like: * This `security_scopes` parameter has a property `scopes` with a `list` containing all these scopes declared above, so: * `security_scopes.scopes` will contain `["me", "items"]` for the *path operation* `read_own_items`. * `security_scopes.scopes` will contain `["me"]` for the *path operation* `read_users_me`, because it is declared in the dependency `get_current_active_user`. - * `security_scopes.scopes` will contain `[]` (nothing) for the *path operation* `read_system_status`, because it didn't declare any `Security` with `scopes`, and its dependency, `get_current_user`, doesn't declare any `scope` either. + * `security_scopes.scopes` will contain `[]` (nothing) for the *path operation* `read_system_status`, because it didn't declare any `Security` with `scopes`, and its dependency, `get_current_user`, doesn't declare any `scopes` either. !!! tip The important and "magic" thing here is that `get_current_user` will have a different list of `scopes` to check for each *path operation*. diff --git a/docs/en/docs/tutorial/cookie-params.md b/docs/en/docs/tutorial/cookie-params.md index 3436a7df3..ac3e2159d 100644 --- a/docs/en/docs/tutorial/cookie-params.md +++ b/docs/en/docs/tutorial/cookie-params.md @@ -46,7 +46,7 @@ First import `Cookie`: Then declare the cookie parameters using the same structure as with `Path` and `Query`. -The first value is the default value, you can pass all the extra validation or annotation parameters: +The first value is the type. You can pass to `Cookie` all the extra validation or annotation parameters. After that you may declare a default value: === "Python 3.10+" diff --git a/docs/en/docs/tutorial/header-params.md b/docs/en/docs/tutorial/header-params.md index bbba90998..0823ece59 100644 --- a/docs/en/docs/tutorial/header-params.md +++ b/docs/en/docs/tutorial/header-params.md @@ -46,7 +46,7 @@ First import `Header`: Then declare the header parameters using the same structure as with `Path`, `Query` and `Cookie`. -The first value is the default value, you can pass all the extra validation or annotation parameters: +The first value is the type. You can pass to `Header` all the extra validation or annotation parameters. After that you may declare a default value: === "Python 3.10+" diff --git a/docs/en/docs/tutorial/query-params-str-validations.md b/docs/en/docs/tutorial/query-params-str-validations.md index 0f792c506..93f2485f7 100644 --- a/docs/en/docs/tutorial/query-params-str-validations.md +++ b/docs/en/docs/tutorial/query-params-str-validations.md @@ -369,7 +369,7 @@ Let's say that you want to declare the `q` query parameter to have a `min_length !!! note Having a default value of any type, including `None`, makes the parameter optional (not required). -## Make it required +## Required params When we don't need to declare more validations or metadata, we can make the `q` query parameter required just by not declaring a default value, like: @@ -457,7 +457,7 @@ There's an alternative way to explicitly declare that a value is required. You c This will let **FastAPI** know that this parameter is required. -### Required with `None` +### Required, can be `None` 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`. @@ -633,7 +633,7 @@ the default of `q` will be: `["foo", "bar"]` and your response will be: } ``` -#### Using `list` +#### Using just `list` You can also use `list` directly instead of `List[str]` (or `list[str]` in Python 3.9+): @@ -852,7 +852,7 @@ The docs will show it like this: -## Exclude from OpenAPI +## Exclude parameter from OpenAPI To exclude a query parameter from the generated OpenAPI schema (and thus, from the automatic documentation systems), set the parameter `include_in_schema` of `Query` to `False`: diff --git a/docs/en/docs/tutorial/response-model.md b/docs/en/docs/tutorial/response-model.md index b85aab5dd..860ddcefb 100644 --- a/docs/en/docs/tutorial/response-model.md +++ b/docs/en/docs/tutorial/response-model.md @@ -192,7 +192,7 @@ That's why in this example we have to declare it in the `response_model` paramet ## Return Type and Data Filtering -Let's continue from the previous example. We wanted to **annotate the function with one type** but return something that includes **more data**. +Let's continue from the previous example. We wanted to **annotate the function with one type** but return something that includes **less data**. We want FastAPI to keep **filtering** the data using the response model. @@ -258,7 +258,7 @@ The most common case would be [returning a Response directly as explained later {!> ../../../docs_src/response_model/tutorial003_02.py!} ``` -This simple case is handled automatically by FastAPI because the return type annotation is the class (or a subclass) of `Response`. +This simple case is handled automatically by FastAPI because the return type annotation is the class (or a subclass of) `Response`. And tools will also be happy because both `RedirectResponse` and `JSONResponse` are subclasses of `Response`, so the type annotation is correct. diff --git a/docs/en/docs/tutorial/security/oauth2-jwt.md b/docs/en/docs/tutorial/security/oauth2-jwt.md index 1c792e3d9..7a1eab55f 100644 --- a/docs/en/docs/tutorial/security/oauth2-jwt.md +++ b/docs/en/docs/tutorial/security/oauth2-jwt.md @@ -47,7 +47,7 @@ Here we are using the recommended one: PyJWT. - But it was updated to use Python-jose instead as it provides all the features from PyJWT plus some extras that you might need later when building integrations with other tools. + But it was updated to use python-jose instead as it provides all the features from PyJWT plus some extras that you might need later when building integrations with other tools. ## Password hashing