@@ -65,6 +65,7 @@ class FastapiEndpoint(models.Model):
6565 "unexpecteed disk space consumption." ,
6666 default = True ,
6767 )
68+ expose_doc_urls = fields .Boolean ("Expose FastAPI docs" , default = True )
6869
6970 @api .depends ("root_path" )
7071 def _compute_root_path (self ):
@@ -150,7 +151,7 @@ def _handle_route_updates(self, vals):
150151 @api .model
151152 def _fastapi_app_fields (self ) -> List [str ]:
152153 """The list of fields requiring to refresh the fastapi app if modified"""
153- return []
154+ return ["expose_doc_urls" ]
154155
155156 def _make_routing_rule (self , options = None ):
156157 """Generator of rule"""
@@ -258,12 +259,15 @@ def _get_app_dependencies_overrides(self) -> Dict[Callable, Callable]:
258259
259260 def _prepare_fastapi_app_params (self ) -> Dict [str , Any ]:
260261 """Return the params to pass to the Fast API app constructor"""
261- return {
262+ to_return = {
262263 "title" : self .name ,
263264 "description" : self .description ,
264265 "middleware" : self ._get_fastapi_app_middlewares (),
265266 "dependencies" : self ._get_fastapi_app_dependencies (),
266267 }
268+ if not self .expose_doc_urls :
269+ to_return |= {"docs_url" : None , "redoc_url" : None , "openapi_url" : None }
270+ return to_return
267271
268272 def _get_fastapi_routers (self ) -> List [APIRouter ]:
269273 """Return the api routers to use for the instance.
0 commit comments