[BugFix] openbb-platform-api: Handle Parmeter Labels Where Platform Hijacks 'title' Annotation (#7025)

* handle parmeter labels where platform hijacks the 'title' annotation

* too-many-branches
This commit is contained in:
Danglewood
2025-02-11 08:24:10 -08:00
committed by GitHub
parent 214e0c9d54
commit 13fc5f71ec

View File

@@ -225,10 +225,6 @@ def set_parameter_options(p: dict, p_schema: dict, providers: list[str]) -> dict
if is_provider_specific:
p["available_providers"] = list(available_providers)
if (title := p_schema.get("title", "")) and title not in providers:
p["label"] = title
return p
@@ -296,6 +292,14 @@ def process_parameter(param: dict, providers: list[str]) -> dict:
p = set_parameter_options(p, p_schema, providers)
p = set_parameter_type(p, p_schema)
if title := p_schema.get("title", ""):
p["label"] = (
p.get("parameter_name", "").replace("_", " ").title()
if ("," in title and title.replace(",", "").islower())
or title.lower() in providers
else title
)
if _widget_config := p_schema.get("x-widget_config", {}):
p.update(_widget_config)
@@ -401,7 +405,7 @@ def get_data_schema_for_widget(openapi_json, operation_id, route: Optional[str]
return None
def data_schema_to_columns_defs( # noqa: PLR0912
def data_schema_to_columns_defs( # noqa: PLR0912 # pylint: disable=too-many-branches
openapi_json, operation_id, provider, route: Optional[str] = None
):
"""Convert data schema to column definitions for the widget."""