1111from fastapi import APIRouter , Depends , HTTPException , status
1212from fastapi .security import APIKeyHeader
1313
14+
1415from ..dependencies import (
1516 authenticated_partner_from_basic_auth_user ,
1617 authenticated_partner_impl ,
1718 odoo_env ,
1819)
19- from ..routers import demo_router , demo_router_doc
20+
21+ # Add imports for TYPE_CHECKING
22+ from typing import TYPE_CHECKING
23+ if TYPE_CHECKING :
24+ from ..routers import demo_router , demo_router_doc
2025
2126
2227class FastapiEndpoint (models .Model ):
@@ -32,6 +37,8 @@ class FastapiEndpoint(models.Model):
3237
3338 def _get_fastapi_routers (self ) -> list [APIRouter ]:
3439 if self .app == "demo" :
40+ # Import here to avoid circular import
41+ from ..routers import demo_router
3542 return [demo_router ]
3643 return super ()._get_fastapi_routers ()
3744
@@ -73,6 +80,8 @@ def _get_app(self):
7380 def _prepare_fastapi_app_params (self ) -> dict [str , Any ]:
7481 params = super ()._prepare_fastapi_app_params ()
7582 if self .app == "demo" :
83+ # Import here to avoid circular import
84+ from ..routers import demo_router_doc
7685 tags_metadata = params .get ("openapi_tags" , []) or []
7786 tags_metadata .append ({"name" : "demo" , "description" : demo_router_doc })
7887 params ["openapi_tags" ] = tags_metadata
@@ -101,4 +110,4 @@ def api_key_based_authenticated_partner_impl(
101110 raise HTTPException (
102111 status_code = status .HTTP_401_UNAUTHORIZED , detail = "Incorrect API Key"
103112 )
104- return partner
113+ return partner
0 commit comments