summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanglewood <85772166+deeleeramone@users.noreply.github.com>2024-07-04 03:00:08 -0700
committerGitHub <noreply@github.com>2024-07-04 10:00:08 +0000
commit5ba54725536a3eb8121f2ed7ea47076789abecea (patch)
tree730367ec296ac75dd1a84148d1806ccb79bc08e2
parent8877f616988e68f470b7c96df300c30607c49f03 (diff)
[BugFix] Fix Provider Interface Body Assignment Of Dict-Like Parameters (#6561)
* fix provider interface body assignment for Dict-like parameters. * 3.9 safe --------- Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com>
-rw-r--r--openbb_platform/core/openbb_core/app/provider_interface.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/openbb_platform/core/openbb_core/app/provider_interface.py b/openbb_platform/core/openbb_core/app/provider_interface.py
index 6c9a558161a..8eb2f5371b6 100644
--- a/openbb_platform/core/openbb_core/app/provider_interface.py
+++ b/openbb_platform/core/openbb_core/app/provider_interface.py
@@ -15,7 +15,7 @@ from typing import (
Union,
)
-from fastapi import Query
+from fastapi import Body, Query
from pydantic import (
BaseModel,
ConfigDict,
@@ -290,6 +290,23 @@ class ProviderInterface(metaclass=SingletonMeta):
else:
default = field.default
+ if (
+ hasattr(annotation, "__name__")
+ and annotation.__name__ in ["Dict", "dict", "Data"] # type: ignore
+ or field.kw_only is True
+ ):
+ return DataclassField(
+ new_name,
+ annotation,
+ Body(
+ default=default,
+ title=provider_name,
+ description=description,
+ alias=field.alias or None,
+ json_schema_extra=getattr(field, "json_schema_extra", None),
+ ),
+ )
+
if query:
# We need to use query if we want the field description to show
# up in the swagger, it's a fastapi limitation