Replies: 6 comments 10 replies
-
Sorry for just seeing this now. The cvb of fastapi-utils is designed to solve the problem of duplicate dependencies, but using Annotated and dependencies in APIRouter can also solve similar problems, such as verify_rbac and CurrentUser. Of course, using classes still has its advantages, especially for those who are accustomed to using classes, as it can be more intuitive. FastAPI design philosophy leans towards using functions, it would be a good choice to follow this mainstream approach. |
Beta Was this translation helpful? Give feedback.
-
Agreed. Class wrapping makes people look more comfortable and is easy to extend, but fastapi_utils doesn't look bright enough in the latest versions of FastAPI and SQLAlchemy Maybe we can think of a better way to implement class wrapping, if not, will continue to use functions |
Beta Was this translation helpful? Give feedback.
-
Look here fastapi-class I think I will combine fastapi-utils and fastapi-class to do something, a new library? Uncertain time, use the function temporarily. The library is compatible with function, and there is no need to modify any interface parameters. |
Beta Was this translation helpful? Give feedback.
-
Hi, @downdawn I have fixed and added some features in fatapi-class, I will add it in its next release ( |
Beta Was this translation helpful? Give feedback.
-
Can look forward to yezz123/fastapi-class#104 |
Beta Was this translation helpful? Give feedback.
-
Interesting: https://github.com/goraje/fastapi-controllers and here: https://github.com/litestar-org/litestar/blob/main/litestar/controller.py |
Beta Was this translation helpful? Give feedback.
-
Hi, @downdawn
I've looked at the class view implementation of fastapi_utils in general, but I'm not very interested
For session, since we're using
SQLAlchemy-2.0
, we'll useasync_db_session.begin()
directly, this seems to make more senseFor
Depends(get_jwt_user)
, we need to make FastAPI >= 0.95.0, then use the Annotated feature, and call it globally, E.g:Like in the fastapi documentation: Share
Annotated
dependenciesBeta Was this translation helpful? Give feedback.
All reactions