diff --git a/src/aaz_dev/cli/controller/az_arg_group_generator.py b/src/aaz_dev/cli/controller/az_arg_group_generator.py index d736f82d..c7ecfa35 100644 --- a/src/aaz_dev/cli/controller/az_arg_group_generator.py +++ b/src/aaz_dev/cli/controller/az_arg_group_generator.py @@ -89,9 +89,9 @@ def __init__(self, name, cmd_ctx, arg): self.props = [] if isinstance(arg, CMDObjectArgBase): if arg.args and arg.additional_props: - # not support to translate argument with both args and additional_props - raise NotImplementedError() - if arg.args: + # treated as AAZFreeFormDictArg + pass + elif arg.args: for a in arg.args: if a.hide: # escape hide argument @@ -116,9 +116,9 @@ def _iter_scopes_by_arg_base(arg, name, scope_define, cmd_ctx): if isinstance(arg, CMDObjectArgBase): if arg.args and arg.additional_props: - # not support to translate argument with both args and additional_props - raise NotImplementedError() - if arg.args: + # treated as AAZFreeFormDictArg so no need to iterate + pass + elif arg.args: for a in arg.args: if a.hide: # escape hide argument @@ -428,6 +428,10 @@ def render_arg_base(arg, cmd_ctx, arg_kwargs=None): if arg.additional_props.any_type is True: arg_type = "AAZFreeFormDictArg" arg_fmt_cls = "AAZFreeFormDictArgFormat" + elif arg.args and arg.additional_props: + # not support object with both args and additional_props, so we treat it as AAZFreeFormDictArg + arg_type = "AAZFreeFormDictArg" + arg_fmt_cls = "AAZFreeFormDictArgFormat" else: assert arg.additional_props.item is not None arg_type = "AAZDictArg" diff --git a/src/aaz_dev/cli/controller/az_operation_generator.py b/src/aaz_dev/cli/controller/az_operation_generator.py index e533c1af..c1664681 100644 --- a/src/aaz_dev/cli/controller/az_operation_generator.py +++ b/src/aaz_dev/cli/controller/az_operation_generator.py @@ -610,14 +610,18 @@ def __init__(self, cmd_ctx, name, schema): self.props = [] self.discriminators = [] if isinstance(schema, CMDObjectSchemaBase): - if schema.props and schema.additional_props: - raise NotImplementedError() if schema.discriminators: + if schema.additional_props: + raise NotImplementedError() for disc in schema.discriminators: disc_key = to_snake_case(disc.property) disc_value = disc.value self.discriminators.append((disc_key, disc_value)) - if schema.props: + + if schema.props and schema.additional_props: + # treat it as AAZFreeFormDictType + pass + elif schema.props: for s in schema.props: s_name = to_snake_case(s.name) self.props.append(s_name) @@ -643,14 +647,23 @@ def _iter_request_scopes_by_schema_base(schema, name, scope_define, arg_key, cmd search_schemas = {} discriminators = [] if isinstance(schema, CMDObjectSchemaBase): - if schema.props and schema.additional_props: - # not support for both props and additional props - raise NotImplementedError() - if schema.discriminators: + if schema.additional_props: + raise NotImplementedError() discriminators.extend(schema.discriminators) - if schema.props: + if schema.props and schema.additional_props: + # treat it as AAZFreeFormDictType + s_name = '{}' + r_key = '.' # if element exist, always fill it + + is_const = False + const_value = None + rendered_schemas.append( + (s_name, None, is_const, const_value, r_key, None, None) + ) + + elif schema.props: for s in schema.props: s_name = s.name s_typ, s_typ_kwargs, cls_builder_name = render_schema(s, cmd_ctx.update_clses, s_name) @@ -833,14 +846,16 @@ def _iter_response_scopes_by_schema_base(schema, name, scope_define, cmd_ctx): search_schemas = {} discriminators = [] if isinstance(schema, CMDObjectSchemaBase): - if schema.props and schema.additional_props: - # not support to parse schema with both props and additional_props - raise NotImplementedError() if schema.discriminators: + if schema.additional_props: + raise NotImplementedError() discriminators.extend(schema.discriminators) - if schema.props: + if schema.props and schema.additional_props: + # treat it as AAZFreeFormDictType + pass + elif schema.props: for s in schema.props: s_name = to_snake_case(s.name) s_typ, s_typ_kwargs, cls_builder_name = render_schema(s, cmd_ctx.response_clses, s_name) @@ -970,7 +985,8 @@ def render_schema_base(schema, cls_map, schema_kwargs=None): if schema.props or schema.discriminators: schema_type = "AAZObjectType" if schema.additional_props: - raise NotImplementedError() + # treat it as AAZFreeFormDictType + schema_type = "AAZFreeFormDictType" elif schema.additional_props: if schema.additional_props.any_type is True: schema_type = "AAZFreeFormDictType"