mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 20:42:26 +00:00
fix: serialize response before fastapi (#6279)
This commit is contained in:
@@ -117,7 +117,7 @@ def build_new_signature(path: str, func: Callable) -> Signature:
|
||||
)
|
||||
|
||||
|
||||
def validate_output(c_out: OBBject) -> OBBject:
|
||||
def validate_output(c_out: OBBject) -> Dict:
|
||||
"""
|
||||
Validate OBBject object.
|
||||
|
||||
@@ -132,8 +132,8 @@ def validate_output(c_out: OBBject) -> OBBject:
|
||||
|
||||
Returns
|
||||
-------
|
||||
OBBject
|
||||
Validated OBBject object.
|
||||
Dict
|
||||
Serialized OBBject.
|
||||
"""
|
||||
|
||||
def is_model(type_):
|
||||
@@ -170,7 +170,7 @@ def validate_output(c_out: OBBject) -> OBBject:
|
||||
for k, v in c_out.model_copy():
|
||||
exclude_fields_from_api(k, v)
|
||||
|
||||
return c_out
|
||||
return c_out.model_dump()
|
||||
|
||||
|
||||
def build_api_wrapper(
|
||||
@@ -188,7 +188,7 @@ def build_api_wrapper(
|
||||
func.__annotations__ = new_annotations_map
|
||||
|
||||
@wraps(wrapped=func)
|
||||
async def wrapper(*args: Tuple[Any], **kwargs: Dict[str, Any]):
|
||||
async def wrapper(*args: Tuple[Any], **kwargs: Dict[str, Any]) -> Dict:
|
||||
user_settings: UserSettings = UserSettings.model_validate(
|
||||
kwargs.pop(
|
||||
"__authenticated_user_settings",
|
||||
@@ -198,8 +198,7 @@ def build_api_wrapper(
|
||||
execute = partial(command_runner.run, path, user_settings)
|
||||
output: OBBject = await execute(*args, **kwargs)
|
||||
|
||||
output = validate_output(output)
|
||||
return output
|
||||
return validate_output(output)
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
@@ -110,7 +110,7 @@ class RegistryMap:
|
||||
fetcher: Fetcher,
|
||||
model_map: dict,
|
||||
):
|
||||
"""Merge json schema extra for different providers"""
|
||||
"""Merge json schema extra for different providers."""
|
||||
model: BaseModel = RegistryMap._get_model(fetcher, "query_params")
|
||||
std_fields = model_map["openbb"]["QueryParams"]["fields"]
|
||||
extra_fields = model_map[provider]["QueryParams"]["fields"]
|
||||
@@ -157,7 +157,6 @@ class RegistryMap:
|
||||
Field(
|
||||
default=provider_str,
|
||||
description="The data provider for the data.",
|
||||
exclude=True,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user