diff --git a/spectree/plugins/falcon_plugin.py b/spectree/plugins/falcon_plugin.py index 892661eb..8539f0b7 100644 --- a/spectree/plugins/falcon_plugin.py +++ b/spectree/plugins/falcon_plugin.py @@ -70,12 +70,11 @@ def __init__(self, spectree): self.INT_ARGS_NAMES = ("num_digits", "min", "max") def register_route(self, app: Any): - self.app = app - self.app.add_route( + app.add_route( self.config.spec_url, self.OPEN_API_ROUTE_CLASS(self.spectree.spec) ) for ui in self.config.page_templates: - self.app.add_route( + app.add_route( f"/{self.config.path}/{ui}", self.DOC_PAGE_ROUTE_CLASS( self.config.page_templates[ui], @@ -95,7 +94,7 @@ def find_node(node): for child in node.children: find_node(child) - for route in self.app._router._roots: + for route in self.spectree.app._router._roots: find_node(route) return routes diff --git a/spectree/plugins/starlette_plugin.py b/spectree/plugins/starlette_plugin.py index f0ef2226..c9d0c391 100644 --- a/spectree/plugins/starlette_plugin.py +++ b/spectree/plugins/starlette_plugin.py @@ -36,15 +36,13 @@ def __init__(self, spectree): self.conv2type = {conv: typ for typ, conv in CONVERTOR_TYPES.items()} def register_route(self, app): - self.app = app - - self.app.add_route( + app.add_route( self.config.spec_url, lambda request: JSONResponse(self.spectree.spec), ) for ui in self.config.page_templates: - self.app.add_route( + app.add_route( f"/{self.config.path}/{ui}", lambda request, ui=ui: HTMLResponse( self.config.page_templates[ui].format( @@ -177,7 +175,7 @@ def parse_route(app, prefix=""): else: parse_route(route, prefix=f"{prefix}{route.path}") - parse_route(self.app) + parse_route(self.spectree.app) return routes def bypass(self, func, method): diff --git a/spectree/spec.py b/spectree/spec.py index af43207c..fc0a172c 100644 --- a/spectree/spec.py +++ b/spectree/spec.py @@ -99,8 +99,6 @@ def register(self, app: Any): self.app = app if self.publish_apidoc: self.backend.register_route(self.app) - else: - self.backend.app = self.app @property def spec(self):