summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormontezdesousa <79287829+montezdesousa@users.noreply.github.com>2024-04-09 08:47:16 +0100
committerGitHub <noreply@github.com>2024-04-09 07:47:16 +0000
commit40c89444cd774e8261452c8732ababf9197d7eb9 (patch)
tree3e90a9ab91adf0d1a33aa11eb546dbf1e2764a0c
parent3f4ab6edf6752eba9f8c3a3fccb6cb0137e19a33 (diff)
[BugFix] - Fix nested router descriptions (#6292)
* fix: get_routers * keep previous structure * rebuild * opt * rename var * simpler * ^
-rw-r--r--openbb_platform/core/openbb_core/app/router.py4
-rw-r--r--openbb_platform/core/openbb_core/app/static/package_builder.py16
-rw-r--r--openbb_platform/openbb/assets/reference.json6
3 files changed, 20 insertions, 6 deletions
diff --git a/openbb_platform/core/openbb_core/app/router.py b/openbb_platform/core/openbb_core/app/router.py
index 68ac8dec3ec..51bfc836d07 100644
--- a/openbb_platform/core/openbb_core/app/router.py
+++ b/openbb_platform/core/openbb_core/app/router.py
@@ -209,7 +209,7 @@ class Router:
return self._api_router.prefix
@property
- def description(self) -> str:
+ def description(self) -> Optional[str]:
"""Description."""
return self._description
@@ -221,7 +221,7 @@ class Router:
def __init__(
self,
prefix: str = "",
- description: str = "",
+ description: Optional[str] = None,
) -> None:
"""Initialize Router."""
self._api_router = APIRouter(
diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py
index 98a6996b8c5..4559d0762b8 100644
--- a/openbb_platform/core/openbb_core/app/static/package_builder.py
+++ b/openbb_platform/core/openbb_core/app/static/package_builder.py
@@ -1684,8 +1684,16 @@ class ReferenceGenerator:
main_router = RouterLoader.from_extensions()
routers = {}
for path in route_map:
- # Strip the command name from the path
- _path = "/".join(path.split("/")[:-1])
- if description := main_router.get_attr(_path, "description"):
- routers[_path] = {"description": description}
+ path_parts = path.split("/")
+ # We start at 2: ["/", "some_router"] "/some_router"
+ i = 2
+ p = "/".join(path_parts[:i])
+ while p != path:
+ if p not in routers:
+ description = main_router.get_attr(p, "description")
+ if description is not None:
+ routers[p] = {"description": description}
+ # We go down the path to include sub-routers
+ i += 1
+ p = "/".join(path_parts[:i])
return routers
diff --git a/openbb_platform/openbb/assets/reference.json b/openbb_platform/openbb/assets/reference.json
index 8356e399770..8517caa78cc 100644
--- a/openbb_platform/openbb/assets/reference.json
+++ b/openbb_platform/openbb/assets/reference.json
@@ -27173,6 +27173,9 @@
"/currency": {
"description": "Foreign exchange (FX) market data."
},
+ "/derivatives": {
+ "description": "Derivatives market data."
+ },
"/economy": {
"description": "Economic data."
},
@@ -27190,6 +27193,9 @@
},
"/news": {
"description": "Financial market news data."
+ },
+ "/regulators": {
+ "description": "Financial market regulators data."
}
}
} \ No newline at end of file