python-injector / injector

Python dependency injection framework, inspired by Guice
BSD 3-Clause "New" or "Revised" License
1.3k stars 81 forks source link

FastAPI support #227

Open Trinkes opened 1 year ago

Trinkes commented 1 year ago

Is there any way to use Injector library with FastAPI endpoints? The ideia would be to replace completely their Depends feature.

jack-michaud commented 1 year ago

I've used fastapi-injector and it works fairly well. https://pypi.org/project/fastapi-injector/

jstasiak commented 1 year ago

Hey @Trinkes, sadly I can't say I know anything about this, I never had a chance to use FastAPI.

In general my answer would be that some custom integration would be required which usually boils down to:

Sadly no good how-to guide explaining that.

@jack-michaud mentioned an interesting integration project which I didn't know about – thank you – maybe that'll help you