Search Options

Results per page
Sort
Preferred Languages
Advance

Results 21 - 26 of 26 for include_router (0.21 sec)

  1. tests/test_annotated.py

        app = FastAPI()
    
        router = APIRouter(prefix="/nested")
    
        @router.get("/test")
        async def test(var: Annotated[str, Query()] = "bar"):
            return {"foo": var}
    
        app.include_router(router)
    
        client = TestClient(app)
    
        response = client.get("/nested/test")
        assert response.status_code == 200
        assert response.json() == {"foo": "bar"}
    
    
    def test_openapi_schema():
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Apr 18 19:40:57 GMT 2024
    - 10.2K bytes
    - Viewed (0)
  2. tests/test_generate_unique_id_function.py

            responses={404: {"model": List[Message]}},
        )
        def post_subrouter(item1: Item, item2: Item):
            return item1, item2  # pragma: nocover
    
        router.include_router(sub_router)
        app.include_router(router, generate_unique_id_function=custom_generate_unique_id3)
        client = TestClient(app)
        response = client.get("/openapi.json")
        data = response.json()
        assert data == {
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Sat Jan 13 15:10:26 GMT 2024
    - 66.7K bytes
    - Viewed (0)
  3. tests/test_custom_middleware_exception.py

            await self.app(scope, wrapper, send)
    
    
    @router.post("/middleware")
    def run_middleware(file: UploadFile = File(..., description="Big File")):
        return {"message": "OK"}
    
    
    app.include_router(router)
    app.add_middleware(ContentSizeLimitMiddleware, max_content_size=2**8)
    
    
    client = TestClient(app)
    
    
    def test_custom_middleware_exception(tmp_path: Path):
        default_pydantic_max_size = 2**16
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Thu Aug 25 21:44:40 GMT 2022
    - 2.8K bytes
    - Viewed (0)
  4. tests/test_sub_callbacks.py

                (e.g. "payment successful").
        """
        # Send the invoice, collect the money, send the notification (the callback)
        return {"msg": "Invoice received"}
    
    
    app.include_router(subrouter, callbacks=events_callback_router.routes)
    
    client = TestClient(app)
    
    
    def test_get():
        response = client.post(
            "/invoices/", json={"id": "fooinvoice", "customer": "John", "total": 5.3}
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 13.8K bytes
    - Viewed (0)
  5. fastapi/routing.py

            users_router = APIRouter()
    
            @users_router.get("/users/")
            def read_users():
                return [{"name": "Rick"}, {"name": "Morty"}]
    
            internal_router.include_router(users_router)
            app.include_router(internal_router)
            ```
            """
            if prefix:
                assert prefix.startswith("/"), "A path prefix must start with '/'"
                assert not prefix.endswith(
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Apr 02 02:48:51 GMT 2024
    - 170.1K bytes
    - Viewed (0)
  6. fastapi/applications.py

            ```python
            from fastapi import FastAPI
    
            from .users import users_router
    
            app = FastAPI()
    
            app.include_router(users_router)
            ```
            """
            self.router.include_router(
                router,
                prefix=prefix,
                tags=tags,
                dependencies=dependencies,
                responses=responses,
    Python
    - Registered: Sun May 05 07:19:11 GMT 2024
    - Last Modified: Tue Apr 02 02:48:51 GMT 2024
    - 172.2K bytes
    - Viewed (0)
Back to top