Skip to content

Commit

Permalink
fix: jans-cli identify if patch property is array
Browse files Browse the repository at this point in the history
  • Loading branch information
devrimyatar committed Sep 21, 2022
1 parent 204daf8 commit 815b5fb
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion jans-cli/cli/config_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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:
Expand All @@ -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':
Expand Down

0 comments on commit 815b5fb

Please sign in to comment.