Python: FastAPI: Add support for APIRouter

This commit is contained in:
Rasmus Wriedt Larsen
2021-09-22 14:37:22 +02:00
parent b1f8b5352b
commit 285de2b4c8
3 changed files with 47 additions and 1 deletions

View File

@@ -23,6 +23,18 @@ private module FastApi {
API::Node instance() { result = API::moduleImport("fastapi").getMember("FastAPI").getReturn() }
}
/**
* Provides models for the `fastapi.APIRouter` class
*
* See https://fastapi.tiangolo.com/tutorial/bigger-applications/.
*/
module APIRouter {
/** Gets a reference to an instance of `fastapi.APIRouter`. */
API::Node instance() {
result = API::moduleImport("fastapi").getMember("APIRouter").getReturn()
}
}
// ---------------------------------------------------------------------------
// routing modeling
// ---------------------------------------------------------------------------
@@ -39,6 +51,8 @@ private module FastApi {
routeAddingMethod = "api_route"
|
this = App::instance().getMember(routeAddingMethod).getACall()
or
this = APIRouter::instance().getMember(routeAddingMethod).getACall()
)
}