Skip to content

Conversation

kuyugama
Copy link
Member

@kuyugama kuyugama commented Aug 2, 2025

This PR introduces layer for compatibility between FunDI and FastAPI. This makes any FunDI's dependency to be usable in FastAPI applications

from fastapi import APIRouter, FastAPI, Header, Request

from fundi import from_
from fundi.compat.fastapi import FunDIRouter

router = FunDIRouter()


def requirement(delulu: bool = Header()):
    return delulu


@router.get("/{pathparam}")
async def index(
    req: Request, interesting: str, pathparam: int, is_delulu: bool = from_(requirement)
):
    print("online-do")
    yield f"Muwahaha, {interesting = !r}, {pathparam = !r}, {is_delulu = !r}, {id(req) = !r}"
    print("post-do")


app = FastAPI()
app.include_router(router)

This also includes the secured(dependency, scopes=[...] to define dependency security scopes (replacement for fastapi's Security(dependency, *, scopes=[...])

@kuyugama kuyugama self-assigned this Aug 2, 2025
@kuyugama kuyugama added the enhancement New feature or request label Aug 2, 2025
@kuyugama kuyugama force-pushed the feat/compat/fastapi branch from df57ee6 to fc6ad00 Compare August 15, 2025 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant