Search Options

Results per page
Sort
Preferred Languages
Advance

Results 211 - 220 of 346 for BaseModel (0.08 sec)

  1. docs_src/response_model/tutorial005_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 = 10.5
    
    
    items = {
        "foo": {"name": "Foo", "price": 50.2},
        "bar": {"name": "Bar", "description": "The Bar fighters", "price": 62, "tax": 20.2},
        "baz": {
            "name": "Baz",
            "description": "There goes my baz",
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Jan 07 14:11:31 UTC 2022
    - 816 bytes
    - Viewed (0)
  2. docs_src/response_model/tutorial005_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: float = 10.5
    
    
    items = {
        "foo": {"name": "Foo", "price": 50.2},
        "bar": {"name": "Bar", "description": "The Bar fighters", "price": 62, "tax": 20.2},
        "baz": {
            "name": "Baz",
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 848 bytes
    - Viewed (0)
  3. tests/test_request_param_model_by_alias.py

    from dirty_equals import IsPartialDict
    from fastapi import Cookie, FastAPI, Header, Query
    from fastapi.testclient import TestClient
    from pydantic import BaseModel, Field
    
    app = FastAPI()
    
    
    class Model(BaseModel):
        param: str = Field(alias="param_alias")
    
    
    @app.get("/query")
    async def query_model(data: Model = Query()):
        return {"param": data.param}
    
    
    @app.get("/header")
    async def header_model(data: Model = Header()):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 20 15:55:38 UTC 2025
    - 2.1K bytes
    - Viewed (0)
  4. tests/test_additional_responses_custom_model_in_callback.py

    from fastapi import APIRouter, FastAPI
    from fastapi.testclient import TestClient
    from inline_snapshot import snapshot
    from pydantic import BaseModel, HttpUrl
    from starlette.responses import JSONResponse
    
    
    class CustomModel(BaseModel):
        a: int
    
    
    app = FastAPI()
    
    callback_router = APIRouter(default_response_class=JSONResponse)
    
    
    @callback_router.get(
        "{$callback_url}/callback/", responses={400: {"model": CustomModel}}
    )
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 5.8K bytes
    - Viewed (0)
  5. tests/test_arbitrary_types.py

    import pytest
    from fastapi import FastAPI
    from fastapi.testclient import TestClient
    from inline_snapshot import snapshot
    
    
    @pytest.fixture(name="client")
    def get_client():
        from pydantic import (
            BaseModel,
            ConfigDict,
            PlainSerializer,
            TypeAdapter,
            WithJsonSchema,
        )
    
        class FakeNumpyArray:
            def __init__(self):
                self.data = [1.0, 2.0, 3.0]
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 20 15:55:38 UTC 2025
    - 3.8K bytes
    - Viewed (0)
  6. docs_src/security/tutorial003_an_py39.py

    from typing import Annotated, Union
    
    from fastapi import Depends, FastAPI, HTTPException, status
    from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
    from pydantic import BaseModel
    
    fake_users_db = {
        "johndoe": {
            "username": "johndoe",
            "full_name": "John Doe",
            "email": "******@****.***",
            "hashed_password": "fakehashedsecret",
            "disabled": False,
        },
        "alice": {
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Mon Nov 24 19:03:06 UTC 2025
    - 2.5K bytes
    - Viewed (0)
  7. docs_src/body_updates/tutorial002_py39.py

    from typing import Union
    
    from fastapi import FastAPI
    from fastapi.encoders import jsonable_encoder
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: Union[str, None] = None
        description: Union[str, None] = None
        price: Union[float, None] = None
        tax: float = 10.5
        tags: list[str] = []
    
    
    items = {
        "foo": {"name": "Foo", "price": 50.2},
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 20 15:55:38 UTC 2025
    - 1K bytes
    - Viewed (0)
  8. tests/test_custom_schema_fields.py

    from typing import Annotated, Optional
    
    from fastapi import FastAPI
    from fastapi.testclient import TestClient
    from pydantic import BaseModel, WithJsonSchema
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        name: str
    
        description: Annotated[
            Optional[str], WithJsonSchema({"type": ["string", "null"]})
        ] = None
    
        model_config = {
            "json_schema_extra": {
                "x-something-internal": {"level": 4},
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 20 15:55:38 UTC 2025
    - 1.3K bytes
    - Viewed (0)
  9. docs/de/docs/tutorial/body.md

    ///
    
    ## Pydantics `BaseModel` importieren { #import-pydantics-basemodel }
    
    Zuerst müssen Sie `BaseModel` von `pydantic` importieren:
    
    {* ../../docs_src/body/tutorial001_py310.py hl[2] *}
    
    ## Ihr Datenmodell erstellen { #create-your-data-model }
    
    Dann deklarieren Sie Ihr Datenmodell als eine Klasse, die von `BaseModel` erbt.
    
    Verwenden Sie Standard-Python-Typen für alle Attribute:
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 24 10:28:19 UTC 2025
    - 7.9K bytes
    - Viewed (0)
  10. tests/test_compat.py

        app = FastAPI()
    
        class Missing:
            def __bool__(self):
                return False
    
        class EmbeddedModel(BaseModel):
            model_config = ConfigDict(arbitrary_types_allowed=True)
            value: Union[str, Missing] = Missing()
    
        class Model(BaseModel):
            model_config = ConfigDict(
                arbitrary_types_allowed=True,
            )
            value: Union[str, Missing] = Missing()
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 12:54:56 UTC 2025
    - 4.2K bytes
    - Viewed (0)
Back to top