Search Options

Results per page
Sort
Preferred Languages
Advance

Results 141 - 150 of 1,916 for FastApi (0.03 sec)

  1. tests/test_union_body_discriminator_annotated.py

    # Ref: https://github.com/fastapi/fastapi/discussions/14495
    
    from typing import Annotated, Union
    
    import pytest
    from fastapi import FastAPI
    from fastapi.testclient import TestClient
    from inline_snapshot import snapshot
    from pydantic import BaseModel
    
    
    @pytest.fixture(name="client")
    def client_fixture() -> TestClient:
        from fastapi import Body
        from pydantic import Discriminator, Tag
    
        class Cat(BaseModel):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 20 15:55:38 UTC 2025
    - 7.7K bytes
    - Viewed (0)
  2. docs/es/docs/tutorial/body-multiple-params.md

    Por ejemplo, ampliando el modelo anterior, podrías decidir que deseas tener otra clave `importance` en el mismo cuerpo, además de `item` y `user`.
    
    Si lo declaras tal cual, debido a que es un valor singular, **FastAPI** asumirá que es un parámetro de query.
    
    Pero puedes instruir a **FastAPI** para que lo trate como otra clave del cuerpo usando `Body`:
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Tue Dec 16 16:33:45 UTC 2025
    - 5.2K bytes
    - Viewed (0)
  3. tests/test_custom_route_class.py

    import pytest
    from fastapi import APIRouter, FastAPI
    from fastapi.routing import APIRoute
    from fastapi.testclient import TestClient
    from starlette.routing import Route
    
    app = FastAPI()
    
    
    class APIRouteA(APIRoute):
        x_type = "A"
    
    
    class APIRouteB(APIRoute):
        x_type = "B"
    
    
    class APIRouteC(APIRoute):
        x_type = "C"
    
    
    router_a = APIRouter(route_class=APIRouteA)
    router_b = APIRouter(route_class=APIRouteB)
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Fri Jun 30 18:25:16 UTC 2023
    - 3.1K bytes
    - Viewed (0)
  4. tests/test_regex_deprecated_params.py

    from typing import Annotated
    
    import pytest
    from fastapi import FastAPI, Query
    from fastapi.exceptions import FastAPIDeprecationWarning
    from fastapi.testclient import TestClient
    
    from .utils import needs_py310
    
    
    def get_client():
        app = FastAPI()
        with pytest.warns(FastAPIDeprecationWarning):
    
            @app.get("/items/")
            async def read_items(
                q: Annotated[str | None, Query(regex="^fixedquery$")] = None,
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Dec 27 18:19:10 UTC 2025
    - 4.6K bytes
    - Viewed (0)
  5. docs/zh/docs/tutorial/handling-errors.md

        "size": "XL"
      }
    }
    
    ```
    
    ### FastAPI `HTTPException` vs Starlette `HTTPException`
    
    **FastAPI** 也提供了自有的 `HTTPException`。
    
    **FastAPI** 的 `HTTPException` 继承自 Starlette 的 `HTTPException` 错误类。
    
    它们之间的唯一区别是,**FastAPI** 的 `HTTPException` 可以在响应中添加响应头。
    
    OAuth 2.0 等安全工具需要在内部调用这些响应头。
    
    因此你可以继续像平常一样在代码中触发 **FastAPI** 的 `HTTPException` 。
    
    但注册异常处理器时,应该注册到来自 Starlette 的 `HTTPException`。
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Oct 11 17:48:49 UTC 2025
    - 8.2K bytes
    - Viewed (0)
  6. docs_src/additional_responses/tutorial002_py39.py

    from typing import Union
    
    from fastapi import FastAPI
    from fastapi.responses import FileResponse
    from pydantic import BaseModel
    
    
    class Item(BaseModel):
        id: str
        value: str
    
    
    app = FastAPI()
    
    
    @app.get(
        "/items/{item_id}",
        response_model=Item,
        responses={
            200: {
                "content": {"image/png": {}},
                "description": "Return the JSON item or an image.",
            }
        },
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 20:41:43 UTC 2025
    - 628 bytes
    - Viewed (0)
  7. docs/en/docs/reference/status.md

    Read more about it in the [FastAPI docs about Response Status Code](https://fastapi.tiangolo.com/tutorial/response-status-code/).
    
    ## Example
    
    ```python
    from fastapi import FastAPI, status
    
    app = FastAPI()
    
    
    @app.get("/items/", status_code=status.HTTP_418_IM_A_TEAPOT)
    def read_items():
        return [{"name": "Plumbus"}, {"name": "Portal Gun"}]
    ```
    
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Thu Apr 18 19:53:19 UTC 2024
    - 871 bytes
    - Viewed (0)
  8. fastapi/security/api_key.py

        The dependency result will be a string containing the key value.
    
        ## Example
    
        ```python
        from fastapi import Depends, FastAPI
        from fastapi.security import APIKeyQuery
    
        app = FastAPI()
    
        query_scheme = APIKeyQuery(name="api_key")
    
    
        @app.get("/items/")
        async def read_items(api_key: str = Depends(query_scheme)):
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 9.6K bytes
    - Viewed (1)
  9. tests/test_typing_python39.py

    from fastapi import FastAPI
    from fastapi.testclient import TestClient
    
    from .utils import needs_py310
    
    
    @needs_py310
    def test_typing():
        types = {
            list[int]: [1, 2, 3],
            dict[str, list[int]]: {"a": [1, 2, 3], "b": [4, 5, 6]},
            set[int]: [1, 2, 3],  # `set` is converted to `list`
            tuple[int, ...]: [1, 2, 3],  # `tuple` is converted to `list`
        }
        for test_type, expect in types.items():
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Sat Mar 18 12:29:59 UTC 2023
    - 709 bytes
    - Viewed (0)
  10. tests/test_router_events.py

    from collections.abc import AsyncGenerator
    from contextlib import asynccontextmanager
    from typing import Union
    
    import pytest
    from fastapi import APIRouter, FastAPI, Request
    from fastapi.testclient import TestClient
    from pydantic import BaseModel
    
    
    class State(BaseModel):
        app_startup: bool = False
        app_shutdown: bool = False
        router_startup: bool = False
        router_shutdown: bool = False
        sub_router_startup: bool = False
    Registered: Sun Dec 28 07:19:09 UTC 2025
    - Last Modified: Wed Dec 17 21:25:59 UTC 2025
    - 7.3K bytes
    - Viewed (0)
Back to top