Search Options

Results per page
Sort
Preferred Languages
Advance

Results 881 - 890 of 1,169 for def2 (0.02 sec)

  1. tests/test_validate_response_recursive/test_validate_response_recursive_pv1.py

    from fastapi.testclient import TestClient
    
    from ..utils import needs_pydanticv1
    
    
    @needs_pydanticv1
    def test_recursive():
        from .app_pv1 import app
    
        client = TestClient(app)
        response = client.get("/items/recursive")
        assert response.status_code == 200, response.text
        assert response.json() == {
            "sub_items": [{"name": "subitem", "sub_items": []}],
            "name": "item",
        }
    
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jul 07 17:12:13 UTC 2023
    - 900 bytes
    - Viewed (0)
  2. docs_src/additional_responses/tutorial003.py

                "content": {
                    "application/json": {
                        "example": {"id": "bar", "value": "The bar tenders"}
                    }
                },
            },
        },
    )
    async def read_item(item_id: str):
        if item_id == "foo":
            return {"id": "foo", "value": "there goes my hero"}
        else:
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Thu Mar 26 19:09:53 UTC 2020
    - 837 bytes
    - Viewed (0)
  3. docs_src/additional_status_codes/tutorial001_an.py

    from typing_extensions import Annotated
    
    app = FastAPI()
    
    items = {"foo": {"name": "Fighters", "size": 6}, "bar": {"name": "Tenders", "size": 3}}
    
    
    @app.put("/items/{item_id}")
    async def upsert_item(
        item_id: str,
        name: Annotated[Union[str, None], Body()] = None,
        size: Annotated[Union[int, None], Body()] = None,
    ):
        if item_id in items:
            item = items[item_id]
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 734 bytes
    - Viewed (0)
  4. docs_src/header_param_models/tutorial001_py39.py

    class CommonHeaders(BaseModel):
        host: str
        save_data: bool
        if_modified_since: Union[str, None] = None
        traceparent: Union[str, None] = None
        x_tag: list[str] = []
    
    
    @app.get("/items/")
    async def read_items(headers: CommonHeaders = Header()):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Sep 17 18:54:10 UTC 2024
    - 390 bytes
    - Viewed (0)
  5. docs_src/cookie_param_models/tutorial002_pv1_an_py39.py

    class Cookies(BaseModel):
        class Config:
            extra = "forbid"
    
        session_id: str
        fatebook_tracker: Union[str, None] = None
        googall_tracker: Union[str, None] = None
    
    
    @app.get("/items/")
    async def read_items(cookies: Annotated[Cookies, Cookie()]):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Sep 17 18:54:10 UTC 2024
    - 406 bytes
    - Viewed (0)
  6. tests/test_tutorial/test_advanced_middleware/test_tutorial001.py

    from fastapi.testclient import TestClient
    
    from docs_src.advanced_middleware.tutorial001 import app
    
    
    def test_middleware():
        client = TestClient(app, base_url="https://testserver")
        response = client.get("/")
        assert response.status_code == 200, response.text
    
        client = TestClient(app)
        response = client.get("/", follow_redirects=False)
        assert response.status_code == 307, response.text
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sun Nov 13 14:26:09 UTC 2022
    - 474 bytes
    - Viewed (0)
  7. docs_src/response_model/tutorial004_py310.py

        "baz": {"name": "Baz", "description": None, "price": 50.2, "tax": 10.5, "tags": []},
    }
    
    
    @app.get("/items/{item_id}", response_model=Item, response_model_exclude_unset=True)
    async def read_item(item_id: str):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Fri Jan 07 14:11:31 UTC 2022
    - 595 bytes
    - Viewed (0)
  8. docs_src/schema_extra_example/tutorial004_py310.py

    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: Item = Body(
            examples=[
                {
                    "name": "Foo",
                    "description": "A very nice Item",
                    "price": 35.4,
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat Jul 01 16:43:29 UTC 2023
    - 786 bytes
    - Viewed (0)
  9. docs_src/path_operation_configuration/tutorial001_py39.py

        description: Union[str, None] = None
        price: float
        tax: Union[float, None] = None
        tags: set[str] = set()
    
    
    @app.post("/items/", response_model=Item, status_code=status.HTTP_201_CREATED)
    async def create_item(item: Item):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Sat May 14 11:59:59 UTC 2022
    - 401 bytes
    - Viewed (0)
  10. docs_src/cookie_param_models/tutorial002_pv1_an.py

    class Cookies(BaseModel):
        class Config:
            extra = "forbid"
    
        session_id: str
        fatebook_tracker: Union[str, None] = None
        googall_tracker: Union[str, None] = None
    
    
    @app.get("/items/")
    async def read_items(cookies: Annotated[Cookies, Cookie()]):
    Registered: Sun Nov 03 07:19:11 UTC 2024
    - Last Modified: Tue Sep 17 18:54:10 UTC 2024
    - 435 bytes
    - Viewed (0)
Back to top