- Sort Score
- Num 10 results
- Language All
Results 261 - 270 of 346 for BaseModel (0.05 seconds)
-
docs_src/body_multiple_params/tutorial001_py310.py
from fastapi import FastAPI, Path 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 = Path(title="The ID of the item to get", ge=0, le=1000), q: str | None = None, item: Item | None = None, ):
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Fri May 13 23:38:22 GMT 2022 - 546 bytes - Click Count (0) -
docs/en/docs/tutorial/body.md
/// ## Import Pydantic's `BaseModel` { #import-pydantics-basemodel } First, you need to import `BaseModel` from `pydantic`: {* ../../docs_src/body/tutorial001_py310.py hl[2] *} ## Create your data model { #create-your-data-model } Then you declare your data model as a class that inherits from `BaseModel`. Use standard Python types for all the attributes:
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Sat Dec 20 15:55:38 GMT 2025 - 6.8K bytes - Click Count (0) -
docs_src/security/tutorial002_py310.py
from fastapi import Depends, FastAPI from fastapi.security import OAuth2PasswordBearer from pydantic import BaseModel app = FastAPI() oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token") class User(BaseModel): username: str email: str | None = None full_name: str | None = None disabled: bool | None = None def fake_decode_token(token): return User(
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Fri Jan 07 14:11:31 GMT 2022 - 711 bytes - Click Count (0) -
docs_src/body_fields/tutorial001_an_py39.py
from typing import Annotated, Union from fastapi import Body, FastAPI from pydantic import BaseModel, Field app = FastAPI() class Item(BaseModel): name: str description: Union[str, None] = Field( default=None, title="The description of the item", max_length=300 ) price: float = Field(gt=0, description="The price must be greater than zero") tax: Union[float, None] = None @app.put("/items/{item_id}")
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Sat Mar 18 12:29:59 GMT 2023 - 582 bytes - Click Count (0) -
docs_src/extra_models/tutorial002_py310.py
from fastapi import FastAPI from pydantic import BaseModel, EmailStr app = FastAPI() class UserBase(BaseModel): username: str email: EmailStr full_name: str | None = None class UserIn(UserBase): password: str class UserOut(UserBase): pass class UserInDB(UserBase): hashed_password: str def fake_password_hasher(raw_password: str):
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Sat Dec 20 15:55:38 GMT 2025 - 798 bytes - Click Count (0) -
docs_src/security/tutorial002_an_py310.py
from typing import Annotated from fastapi import Depends, FastAPI from fastapi.security import OAuth2PasswordBearer from pydantic import BaseModel app = FastAPI() oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token") class User(BaseModel): username: str email: str | None = None full_name: str | None = None disabled: bool | None = None def fake_decode_token(token): return User(
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Sat Mar 18 12:29:59 GMT 2023 - 761 bytes - Click Count (0) -
docs_src/path_operation_configuration/tutorial004_py310.py
from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() class Item(BaseModel): name: str description: str | None = None price: float tax: float | None = None tags: set[str] = set() @app.post("/items/", response_model=Item, summary="Create an item") async def create_item(item: Item): """ Create an item with all the information: - **name**: each item must have a name
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Fri Jan 07 14:11:31 GMT 2022 - 638 bytes - Click Count (0) -
tests/test_dependency_duplicates.py
from fastapi import Depends, FastAPI from fastapi.testclient import TestClient from pydantic import BaseModel app = FastAPI() client = TestClient(app) class Item(BaseModel): data: str def duplicate_dependency(item: Item): return item def dependency(item2: Item): return item2 def sub_duplicate_dependency( item: Item, sub_item: Item = Depends(duplicate_dependency) ):
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Sat Dec 27 18:19:10 GMT 2025 - 8K bytes - Click Count (0) -
docs/es/docs/tutorial/body.md
/// ## Importar `BaseModel` de Pydantic { #import-pydantics-basemodel } Primero, necesitas importar `BaseModel` de `pydantic`: {* ../../docs_src/body/tutorial001_py310.py hl[2] *} ## Crea tu modelo de datos { #create-your-data-model } Luego, declaras tu modelo de datos como una clase que hereda de `BaseModel`. Usa tipos estándar de Python para todos los atributos:Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 17 20:41:43 GMT 2025 - 7.6K bytes - Click Count (0) -
docs_src/path_operation_advanced_configuration/tutorial004_py39.py
from typing import Union from fastapi import FastAPI from pydantic import BaseModel app = FastAPI() class Item(BaseModel): name: str description: Union[str, None] = None price: float tax: Union[float, None] = None tags: set[str] = set() @app.post("/items/", response_model=Item, summary="Create an item") async def create_item(item: Item): """ Create an item with all the information:
Created: Sun Dec 28 07:19:09 GMT 2025 - Last Modified: Wed Dec 10 08:55:32 GMT 2025 - 712 bytes - Click Count (0)