From 0bc85b328b3ae1829cf9e2f579ab8913cc0d2e0d Mon Sep 17 00:00:00 2001 From: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> Date: Wed, 20 Mar 2024 08:56:43 +0100 Subject: [PATCH] Allow kwargs on POST endpoints --- .../core/openbb_core/app/static/package_builder.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openbb_platform/core/openbb_core/app/static/package_builder.py b/openbb_platform/core/openbb_core/app/static/package_builder.py index 917f9ff03dff..793f82731c6c 100644 --- a/openbb_platform/core/openbb_core/app/static/package_builder.py +++ b/openbb_platform/core/openbb_core/app/static/package_builder.py @@ -343,7 +343,7 @@ def build(cls, path: str) -> str: code += "\nfrom pydantic import BaseModel" code += "\nfrom inspect import Parameter" code += "\nimport typing" - code += "\nfrom typing import List, Dict, Union, Optional, Literal" + code += "\nfrom typing import List, Dict, Union, Optional, Literal, Any" code += "\nfrom annotated_types import Ge, Le, Gt, Lt" code += "\nfrom warnings import warn, simplefilter" if sys.version_info < (3, 9): @@ -567,6 +567,10 @@ def format_params( for name, param in parameter_map.items(): if name == "extra_params": formatted[name] = Parameter(name="kwargs", kind=Parameter.VAR_KEYWORD) + elif name == "kwargs": + formatted["**" + name] = Parameter( + name="kwargs", kind=Parameter.VAR_KEYWORD, annotation=Any + ) elif name == "provider_choices": fields = param.annotation.__args__[0].__dataclass_fields__ field = fields["provider"]