From 5ba54725536a3eb8121f2ed7ea47076789abecea Mon Sep 17 00:00:00 2001 From: Danglewood <85772166+deeleeramone@users.noreply.github.com> Date: Thu, 4 Jul 2024 03:00:08 -0700 Subject: [PATCH] [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> --- .../openbb_core/app/provider_interface.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/openbb_platform/core/openbb_core/app/provider_interface.py b/openbb_platform/core/openbb_core/app/provider_interface.py index 6c9a558161ae..8eb2f5371b62 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 @@ Union, ) -from fastapi import Query +from fastapi import Body, Query from pydantic import ( BaseModel, ConfigDict, @@ -290,6 +290,23 @@ def _create_field( 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