Search Options

Results per page
Sort
Preferred Languages
Advance

Results 151 - 160 of 346 for BaseModel (0.04 sec)

  1. tests/test_request_params/test_header/test_required_str.py

    from fastapi.testclient import TestClient
    from pydantic import BaseModel, Field
    
    app = FastAPI()
    
    # =====================================================================================
    # Without aliases
    
    
    @app.get("/required-str")
    async def read_required_str(p: Annotated[str, Header()]):
        return {"p": p}
    
    
    class HeaderModelRequiredStr(BaseModel):
        p: str
    
    
    @app.get("/model-required-str")
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 10K bytes
    - Viewed (0)
  2. docs_src/body_nested_models/tutorial007_py39.py

    from fastapi import FastAPI
    from pydantic import BaseModel, HttpUrl
    
    app = FastAPI()
    
    
    class Image(BaseModel):
        url: HttpUrl
        name: str
    
    
    class Item(BaseModel):
        name: str
        description: Union[str, None] = None
        price: float
        tax: Union[float, None] = None
        tags: set[str] = set()
        images: Union[list[Image], None] = None
    
    
    class Offer(BaseModel):
        name: str
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat May 14 11:59:59 UTC 2022
    - 570 bytes
    - Viewed (0)
  3. tests/test_request_params/test_form/test_optional_str.py

    from typing import Annotated, Optional
    
    import pytest
    from fastapi import FastAPI, Form
    from fastapi.testclient import TestClient
    from pydantic import BaseModel, Field
    
    from .utils import get_body_model_name
    
    app = FastAPI()
    
    # =====================================================================================
    # Without aliases
    
    
    @app.post("/optional-str", operation_id="optional_str")
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 8.9K bytes
    - Viewed (0)
  4. tests/test_request_params/test_query/test_optional_list.py

    from pydantic import BaseModel, Field
    
    app = FastAPI()
    
    # =====================================================================================
    # Without aliases
    
    
    @app.get("/optional-list-str")
    async def read_optional_list_str(
        p: Annotated[Optional[list[str]], Query()] = None,
    ):
        return {"p": p}
    
    
    class QueryModelOptionalListStr(BaseModel):
        p: Optional[list[str]] = None
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 9.1K bytes
    - Viewed (0)
  5. tests/test_request_params/test_query/test_required_str.py

    from fastapi.testclient import TestClient
    from pydantic import BaseModel, Field
    
    app = FastAPI()
    
    # =====================================================================================
    # Without aliases
    
    
    @app.get("/required-str")
    async def read_required_str(p: str):
        return {"p": p}
    
    
    class QueryModelRequiredStr(BaseModel):
        p: str
    
    
    @app.get("/model-required-str")
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 9.9K bytes
    - Viewed (0)
  6. tests/forward_reference_type.py

    from pydantic import BaseModel
    
    
    def forwardref_method(input: "ForwardRefModel") -> "ForwardRefModel":
        return ForwardRefModel(x=input.x + 1)
    
    
    class ForwardRefModel(BaseModel):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Tue Dec 02 17:23:14 UTC 2025
    - 196 bytes
    - Viewed (0)
  7. tests/test_forms_single_model.py

    from fastapi.testclient import TestClient
    from pydantic import BaseModel, Field
    
    app = FastAPI()
    
    
    class FormModel(BaseModel):
        username: str
        lastname: str
        age: Optional[int] = None
        tags: list[str] = ["foo", "bar"]
        alias_with: str = Field(alias="with", default="nothing")
    
    
    class FormModelExtraAllow(BaseModel):
        param: str
    
        model_config = {"extra": "allow"}
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 3.4K bytes
    - Viewed (0)
  8. tests/test_computed_fields.py

    @pytest.fixture(name="client")
    def get_client(request):
        separate_input_output_schemas = request.param
        app = FastAPI(separate_input_output_schemas=separate_input_output_schemas)
    
        from pydantic import BaseModel, computed_field
    
        class Rectangle(BaseModel):
            width: int
            length: int
    
            @computed_field
            @property
            def area(self) -> int:
                return self.width * self.length
    
        @app.get("/")
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 20 15:55:38 UTC 2025
    - 3.2K bytes
    - Viewed (0)
  9. docs_src/app_testing/app_b_an_py310/main.py

    from fastapi import FastAPI, Header, HTTPException
    from pydantic import BaseModel
    
    fake_secret_token = "coneofsilence"
    
    fake_db = {
        "foo": {"id": "foo", "title": "Foo", "description": "There goes my hero"},
        "bar": {"id": "bar", "title": "Bar", "description": "The bartenders"},
    }
    
    app = FastAPI()
    
    
    class Item(BaseModel):
        id: str
        title: str
        description: str | None = None
    
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Thu Aug 15 22:31:16 UTC 2024
    - 1.1K bytes
    - Viewed (0)
  10. docs_src/request_form_models/tutorial002_py39.py

    from fastapi import FastAPI, Form
    from pydantic import BaseModel
    
    app = FastAPI()
    
    
    class FormData(BaseModel):
        username: str
        password: str
        model_config = {"extra": "forbid"}
    
    
    @app.post("/login/")
    async def login(data: FormData = Form()):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 267 bytes
    - Viewed (0)
Back to top