From 815b5fb9b9a248d2fe9ce13253eadeabebe30a85 Mon Sep 17 00:00:00 2001 From: Mustafa Baser Date: Wed, 21 Sep 2022 14:05:25 +0300 Subject: [PATCH] fix: jans-cli identify if patch property is array --- jans-cli/cli/config_cli.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/jans-cli/cli/config_cli.py b/jans-cli/cli/config_cli.py index 8b2c24d7af9..17cc9b57e2f 100755 --- a/jans-cli/cli/config_cli.py +++ b/jans-cli/cli/config_cli.py @@ -1563,7 +1563,6 @@ def process_delete(self, endpoint): self.display_menu(endpoint.parent) def process_patch(self, endpoint): - if endpoint.info['operationId'] == 'patch-user-by-inum': schema = self.cfg_yml['components']['schemas']['CustomAttribute'].copy() schema['__schema_name__'] = 'CustomAttribute' @@ -1580,6 +1579,14 @@ def process_patch(self, endpoint): schema['__schema_name__'] = 'PatchRequest' model = getattr(swagger_client.models, 'PatchRequest') + parent_schema = {} + for m in endpoint.parent: + if m.method == 'get': + schema_ref = m.info.get('responses', {}).get('200', {}).get('content', {}).get('application/json', {}).get('schema', {}).get('$ref') + if schema_ref: + parent_schema = self.get_schema_from_reference(schema_ref) + break + url_param_val = None url_param = self.get_endpiont_url_param(endpoint) if 'name' in url_param: @@ -1601,6 +1608,11 @@ def process_patch(self, endpoint): if my_op_mode == 'scim': data.path = data.path.replace('/', '.') + if parent_schema and 'properties' in parent_schema: + for prop_ in parent_schema['properties']: + if data.path.lstrip('/') == prop_: + if parent_schema['properties'][prop_]['type'] == 'array': + data.value = data.value.split('_,') body.append(data) selection = self.get_input(text='Another patch operation?', values=['y', 'n']) if selection == 'n':