Skip to content

Commit 5cb4d2b

Browse files
committed
Merge dev into main
2 parents 117fadc + 6d2cc46 commit 5cb4d2b

4 files changed

Lines changed: 31 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# OSBot-Fast-API
22

3-
![Current Release](https://img.shields.io/badge/release-v0.38.0-blue)
3+
![Current Release](https://img.shields.io/badge/release-v0.38.2-blue)
44
![Python](https://img.shields.io/badge/python-3.8+-green)
55
![FastAPI](https://img.shields.io/badge/FastAPI-0.100+-red)
66
![Type-Safe](https://img.shields.io/badge/Type--Safe-✓-brightgreen)

osbot_fast_api/utils/Fast_API_Utils.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ def fastapi_routes(self, router=None, include_default=False, expand_mounts=False
1515
router = self.app
1616
routes = []
1717
for route in router.routes:
18+
# FastAPI >= 0.137: include_router() no longer flattens child routes into
19+
# app.routes; it inserts an _IncludedRouter wrapper (a BaseRoute with no .path).
20+
# Expand it into its effective routes so introspection keeps working.
21+
if route.__class__.__name__ == '_IncludedRouter':
22+
routes.extend(self.fastapi_routes__from_included(route,
23+
include_default=include_default,
24+
expand_mounts=expand_mounts,
25+
route_prefix=route_prefix))
26+
continue
27+
1828
if include_default is False and route.path in FAST_API_DEFAULT_ROUTES_PATHS:
1929
continue
2030
if type(route) is Mount:
@@ -39,4 +49,22 @@ def fastapi_routes(self, router=None, include_default=False, expand_mounts=False
3949
route_path = route_prefix + route.path
4050
route_to_add = {"http_path": route_path, "method_name": route.name, "http_methods": methods}
4151
routes.append(route_to_add)
52+
return routes
53+
54+
def fastapi_routes__from_included(self, included, include_default, expand_mounts, route_prefix):
55+
routes = []
56+
for candidate in included.effective_candidates():
57+
if candidate.__class__.__name__ == '_IncludedRouter': # nested include_router
58+
routes.extend(self.fastapi_routes__from_included(candidate,
59+
include_default = include_default,
60+
expand_mounts = expand_mounts,
61+
route_prefix = route_prefix))
62+
continue
63+
path = candidate.path # effective, prefix already applied
64+
if include_default is False and path in FAST_API_DEFAULT_ROUTES_PATHS:
65+
continue
66+
methods = sorted(candidate.methods) if getattr(candidate, 'methods', None) else [] # websocket → []
67+
routes.append({"http_path" : route_prefix + path,
68+
"method_name" : candidate.name,
69+
"http_methods": methods})
4270
return routes

osbot_fast_api/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.38.0
1+
v0.38.2

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "osbot_fast_api"
3-
version = "v0.38.0"
3+
version = "v0.38.2"
44
description = "OWASP Security Bot - Fast API"
55
authors = ["Dinis Cruz <dinis.cruz@owasp.org>"]
66
license = "MIT"

0 commit comments

Comments
 (0)