- Sort Score
- Num 10 results
- Language All
Results 161 - 170 of 542 for Annotated (0.05 seconds)
-
docs_src/dependencies/tutorial014_an_py310.py
import time from typing import Annotated from fastapi import Depends, FastAPI, HTTPException from fastapi.responses import StreamingResponse from sqlmodel import Field, Session, SQLModel, create_engine engine = create_engine("postgresql+psycopg://postgres:postgres@localhost/db") class User(SQLModel, table=True): id: int | None = Field(default=None, primary_key=True) name: str app = FastAPI() def get_session():
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Mon Sep 29 03:29:38 GMT 2025 - 957 bytes - Click Count (0) -
docs/ja/docs/tutorial/dependencies/index.md
`Depends`を渡すだけで、**FastAPI** が残りの処理をしてくれます。 /// ## `Annotated` 依存関係の共有 { #share-annotated-dependencies } 上の例では、ほんの少し **コードの重複** があることがわかります。 `common_parameters()` 依存関係を使う必要があるときは、型アノテーションと `Depends()` を含むパラメータ全体を書く必要があります: ```Python commons: Annotated[dict, Depends(common_parameters)] ``` しかし、`Annotated` を使用しているので、その `Annotated` 値を変数に格納して複数箇所で使えます:Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Fri Mar 20 14:07:17 GMT 2026 - 11.9K bytes - Click Count (0) -
tests/test_custom_schema_fields.py
from typing import Annotated from fastapi import FastAPI from fastapi.testclient import TestClient from pydantic import BaseModel, WithJsonSchema app = FastAPI() class Item(BaseModel): name: str description: Annotated[str | None, WithJsonSchema({"type": ["string", "null"]})] = ( None ) model_config = { "json_schema_extra": { "x-something-internal": {"level": 4}, }
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Tue Feb 17 09:59:14 GMT 2026 - 1.3K bytes - Click Count (0) -
docs_src/schema_extra_example/tutorial005_an_py310.py
from typing import Annotated from fastapi import Body, FastAPI from pydantic import BaseModel app = FastAPI() class Item(BaseModel): name: str description: str | None = None price: float tax: float | None = None @app.put("/items/{item_id}") async def update_item( *, item_id: int, item: Annotated[ Item, Body( openapi_examples={
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sat Aug 26 18:03:13 GMT 2023 - 1.5K bytes - Click Count (0) -
docs_src/schema_extra_example/tutorial004_an_py310.py
from typing import Annotated from fastapi import Body, FastAPI from pydantic import BaseModel app = FastAPI() class Item(BaseModel): name: str description: str | None = None price: float tax: float | None = None @app.put("/items/{item_id}") async def update_item( *, item_id: int, item: Annotated[ Item, Body( examples=[ {
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sat Jul 01 16:43:29 GMT 2023 - 917 bytes - Click Count (0) -
docs_src/custom_request_and_route/tutorial002_an_py310.py
from collections.abc import Callable from typing import Annotated from fastapi import Body, FastAPI, HTTPException, Request, Response from fastapi.exceptions import RequestValidationError from fastapi.routing import APIRoute class ValidationErrorLoggingRoute(APIRoute): def get_route_handler(self) -> Callable: original_route_handler = super().get_route_handler() async def custom_route_handler(request: Request) -> Response:
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Wed Dec 10 08:55:32 GMT 2025 - 974 bytes - Click Count (0) -
docs_src/dependencies/tutorial008d_an_py310.py
from typing import Annotated from fastapi import Depends, FastAPI, HTTPException app = FastAPI() class InternalError(Exception): pass def get_username(): try: yield "Rick" except InternalError: print("We don't swallow the internal error here, we raise again 😎") raise @app.get("/items/{item_id}") def get_item(item_id: str, username: Annotated[str, Depends(get_username)]):
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 734 bytes - Click Count (0) -
docs_src/server_sent_events/tutorial004_py310.py
from collections.abc import AsyncIterable from typing import Annotated from fastapi import FastAPI, Header from fastapi.sse import EventSourceResponse, ServerSentEvent from pydantic import BaseModel app = FastAPI() class Item(BaseModel): name: str price: float items = [ Item(name="Plumbus", price=32.99), Item(name="Portal Gun", price=999.99), Item(name="Meeseeks Box", price=49.99), ]
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Sun Mar 01 09:21:52 GMT 2026 - 795 bytes - Click Count (0) -
tests/test_list_bytes_file_order_preserved_issue_14811.py
""" Regression test: preserve order when using list[bytes] + File() See https://github.com/fastapi/fastapi/discussions/14811 Fixed in PR: https://github.com/fastapi/fastapi/pull/14884 """ from typing import Annotated import anyio import pytest from fastapi import FastAPI, File from fastapi.testclient import TestClient from starlette.datastructures import UploadFile as StarletteUploadFile def test_list_bytes_file_preserves_order(
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Tue Feb 10 12:14:38 GMT 2026 - 1.4K bytes - Click Count (0) -
docs_src/request_files/tutorial002_an_py310.py
from typing import Annotated from fastapi import FastAPI, File, UploadFile from fastapi.responses import HTMLResponse app = FastAPI() @app.post("/files/") async def create_files(files: Annotated[list[bytes], File()]): return {"file_sizes": [len(file) for file in files]} @app.post("/uploadfiles/") async def create_upload_files(files: list[UploadFile]): return {"filenames": [file.filename for file in files]}
Created: Sun Apr 05 07:19:11 GMT 2026 - Last Modified: Thu Feb 12 13:19:43 GMT 2026 - 826 bytes - Click Count (0)