mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 04:31:13 +00:00
[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>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user