diff --git a/midcli/command/generic_call/__init__.py b/midcli/command/generic_call/__init__.py index 0cea71a..52417b4 100644 --- a/midcli/command/generic_call/__init__.py +++ b/midcli/command/generic_call/__init__.py @@ -39,7 +39,10 @@ def _process_method(self, method): def _create_arguments(self): for i, item in enumerate(self.method["accepts"] or []): if i == self.splice_kwargs: - if "anyOf" in item and all(option.get("type") == "object" for option in item["anyOf"]): + # Handle discriminated unions (oneOf with discriminator) and anyOf unions + if ("anyOf" in item or "oneOf" in item) and all( + option.get("type") == "object" for option in item.get("anyOf") or item.get("oneOf") + ): # FIXME: Remove this when we use proper field discriminators in API item = {"type": "object", "_attrs_order_": []} diff --git a/midcli/gui/base/steps/input_delegate.py b/midcli/gui/base/steps/input_delegate.py index eb48ec2..63d5253 100644 --- a/midcli/gui/base/steps/input_delegate.py +++ b/midcli/gui/base/steps/input_delegate.py @@ -29,7 +29,9 @@ def create_input_delegate(input: "Input", schema: dict) -> "InputDelegate": type.add("null") elif isinstance(v, str): type.add("string") - elif "anyOf" in schema and (type := {s["type"] for s in schema["anyOf"]}): + elif ("anyOf" in schema or "oneOf" in schema) and ( + type := {s["type"] for s in schema.get("anyOf", []) or schema.get("oneOf", [])} + ): pass else: raise ValueError(f"Unable to create input delegate for schema {schema!r}")