Skip to content

Commit

Permalink
🐛 fix(spectree): remove unnecessary app attribute from backend
Browse files Browse the repository at this point in the history
The app attribute was being set in the backend, but it was not being used. This commit removes the app attribute from the backend.
  • Loading branch information
AndreasBBS committed May 14, 2023
1 parent f0ea3c8 commit 7d585b6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
7 changes: 3 additions & 4 deletions spectree/plugins/falcon_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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
Expand Down
8 changes: 3 additions & 5 deletions spectree/plugins/starlette_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 0 additions & 2 deletions spectree/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 7d585b6

Please sign in to comment.