@@ -64,6 +64,7 @@ class FastapiEndpoint(models.Model):
6464 "unexpecteed disk space consumption." ,
6565 default = True ,
6666 )
67+ expose_doc_urls = fields .Boolean ("Expose FastAPI docs" , default = True )
6768
6869 @api .depends ("root_path" )
6970 def _compute_root_path (self ):
@@ -149,7 +150,7 @@ def _handle_route_updates(self, vals):
149150 @api .model
150151 def _fastapi_app_fields (self ) -> List [str ]:
151152 """The list of fields requiring to refresh the fastapi app if modified"""
152- return []
153+ return ["expose_doc_urls" ]
153154
154155 def _make_routing_rule (self , options = None ):
155156 """Generator of rule"""
@@ -325,12 +326,15 @@ def _get_app_dependencies_overrides(self) -> Dict[Callable, Callable]:
325326
326327 def _prepare_fastapi_app_params (self ) -> Dict [str , Any ]:
327328 """Return the params to pass to the Fast API app constructor"""
328- return {
329+ to_return = {
329330 "title" : self .name ,
330331 "description" : self .description ,
331332 "middleware" : self ._get_fastapi_app_middlewares (),
332333 "dependencies" : self ._get_fastapi_app_dependencies (),
333334 }
335+ if not self .expose_doc_urls :
336+ to_return |= {"docs_url" : None , "redoc_url" : None , "openapi_url" : None }
337+ return to_return
334338
335339 def _get_fastapi_routers (self ) -> List [APIRouter ]:
336340 """Return the api routers to use for the instance.
0 commit comments