- Sort Score
- Result 10 results
- Languages All
Results 171 - 180 of 617 for depende (0.03 sec)
-
tests/test_top_level_security_scheme_in_openapi.py
# Ref: https://github.com/fastapi/fastapi/issues/14271 from fastapi import Depends, FastAPI from fastapi.security import HTTPBearer from fastapi.testclient import TestClient from inline_snapshot import snapshot app = FastAPI() bearer_scheme = HTTPBearer() @app.get("/", dependencies=[Depends(bearer_scheme)]) async def get_root(): return {"message": "Hello, World!"}
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Mon Nov 24 19:03:06 UTC 2025 - 1.9K bytes - Viewed (0) -
docs/zh/docs/tutorial/dependencies/index.md
然后,依赖项函数返回包含这些值的 `dict`。 ### 导入 `Depends` {* ../../docs_src/dependencies/tutorial001.py hl[3] *} ### 声明依赖项 与在*路径操作函数*参数中使用 `Body`、`Query` 的方式相同,声明依赖项需要使用 `Depends` 和一个新的参数: {* ../../docs_src/dependencies/tutorial001.py hl[15,20] *} 虽然,在路径操作函数的参数中使用 `Depends` 的方式与 `Body`、`Query` 相同,但 `Depends` 的工作方式略有不同。 这里只能传给 Depends 一个参数。 且该参数必须是可调用对象,比如函数。 该函数接收的参数和*路径操作函数*的参数一样。Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Mon Nov 18 02:25:44 UTC 2024 - 7K bytes - Viewed (0) -
tests/test_security_api_key_header_optional.py
from typing import Optional from fastapi import Depends, FastAPI, Security from fastapi.security import APIKeyHeader from fastapi.testclient import TestClient from pydantic import BaseModel app = FastAPI() api_key = APIKeyHeader(name="key", auto_error=False) class User(BaseModel): username: str def get_current_user(oauth_header: Optional[str] = Security(api_key)): if oauth_header is None: return None
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 2K bytes - Viewed (0) -
tests/test_generic_parameterless_depends.py
from typing import Annotated, TypeVar from fastapi import Depends, FastAPI from fastapi.testclient import TestClient app = FastAPI() T = TypeVar("T") Dep = Annotated[T, Depends()] class A: pass class B: pass @app.get("/a") async def a(dep: Dep[A]): return {"cls": dep.__class__.__name__} @app.get("/b") async def b(dep: Dep[B]): return {"cls": dep.__class__.__name__}
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Wed Dec 17 21:25:59 UTC 2025 - 1.8K bytes - Viewed (0) -
tests/test_param_in_path_and_dependency.py
from fastapi import Depends, FastAPI from fastapi.testclient import TestClient app = FastAPI() async def user_exists(user_id: int): return True @app.get("/users/{user_id}", dependencies=[Depends(user_exists)]) async def read_users(user_id: int): pass client = TestClient(app) def test_read_users(): response = client.get("/users/42") assert response.status_code == 200, response.text
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Fri Jun 30 18:25:16 UTC 2023 - 3.1K bytes - Viewed (0) -
tests/test_security_api_key_header.py
from fastapi import Depends, FastAPI, Security from fastapi.security import APIKeyHeader from fastapi.testclient import TestClient from pydantic import BaseModel app = FastAPI() api_key = APIKeyHeader(name="key") class User(BaseModel): username: str def get_current_user(oauth_header: str = Security(api_key)): user = User(username=oauth_header) return user @app.get("/users/me")
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Mon Nov 24 19:03:06 UTC 2025 - 1.9K bytes - Viewed (0) -
tests/test_security_api_key_header_description.py
from fastapi import Depends, FastAPI, Security from fastapi.security import APIKeyHeader from fastapi.testclient import TestClient from pydantic import BaseModel app = FastAPI() api_key = APIKeyHeader(name="key", description="An API Key Header") class User(BaseModel): username: str def get_current_user(oauth_header: str = Security(api_key)): user = User(username=oauth_header) return user
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Mon Nov 24 19:03:06 UTC 2025 - 2.1K bytes - Viewed (0) -
docs/ru/docs/advanced/advanced-dependencies.md
В версии 0.121.0 FastAPI добавил поддержку `Depends(scope="function")` для зависимостей с `yield`. При использовании `Depends(scope="function")` код после `yield` выполняется сразу после завершения *функции-обработчика пути*, до отправки ответа клиенту. А при использовании `Depends(scope="request")` (значение по умолчанию) код после `yield` выполняется после отправки ответа.
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Thu Dec 11 21:25:03 UTC 2025 - 14.1K bytes - Viewed (0) -
docs/de/docs/advanced/security/oauth2-scopes.md
`Security` ist tatsächlich eine Unterklasse von `Depends` und hat nur noch einen zusätzlichen Parameter, den wir später kennenlernen werden. Durch die Verwendung von `Security` anstelle von `Depends` weiß **FastAPI** jedoch, dass es Sicherheits-Scopes deklarieren, intern verwenden und die API mit OpenAPI dokumentieren kann.
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Sat Sep 20 15:10:09 UTC 2025 - 15.7K bytes - Viewed (0) -
tests/test_security_openid_connect.py
from fastapi import Depends, FastAPI, Security from fastapi.security.open_id_connect_url import OpenIdConnect from fastapi.testclient import TestClient from pydantic import BaseModel app = FastAPI() oid = OpenIdConnect(openIdConnectUrl="/openid") class User(BaseModel): username: str def get_current_user(oauth_header: str = Security(oid)): user = User(username=oauth_header) return user
Registered: Sun Dec 28 07:19:09 UTC 2025 - Last Modified: Mon Nov 24 19:03:06 UTC 2025 - 2.3K bytes - Viewed (0)