Skip to content

Commit

Permalink
[BugFix] Fix Provider Interface Body Assignment Of Dict-Like Paramete…
Browse files Browse the repository at this point in the history
…rs (#6561)

* fix provider interface body assignment for Dict-like parameters.

* 3.9 safe

---------

Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com>
  • Loading branch information
deeleeramone and IgorWounds authored Jul 4, 2024
1 parent 8877f61 commit 5ba5472
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion openbb_platform/core/openbb_core/app/provider_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Union,
)

from fastapi import Query
from fastapi import Body, Query
from pydantic import (
BaseModel,
ConfigDict,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5ba5472

Please sign in to comment.