@@ -322,35 +322,7 @@ def validate_default_params(self):
322
322
if self .schema is None :
323
323
log .error ("[red][✗] Pipeline schema not found" )
324
324
try :
325
- # TODO add support for nested parameters
326
- # Make copy of schema and remove required flags
327
- schema_no_required = copy .deepcopy (self .schema )
328
- if "required" in schema_no_required :
329
- schema_no_required .pop ("required" )
330
- for keyword in ["allOf" , "anyOf" , "oneOf" ]:
331
- if keyword in schema_no_required :
332
- for i , kw_content in enumerate (schema_no_required [keyword ]):
333
- if "required" in kw_content :
334
- schema_no_required [keyword ][i ].pop ("required" )
335
- schema_no_required [keyword ] = [
336
- kw_content for kw_content in schema_no_required [keyword ] if kw_content
337
- ]
338
- if not schema_no_required [keyword ]:
339
- schema_no_required .pop (keyword )
340
- for group_key , group in schema_no_required .get (self .defs_notation , {}).items ():
341
- if "required" in group :
342
- schema_no_required [self .defs_notation ][group_key ].pop ("required" )
343
- for keyword in ["allOf" , "anyOf" , "oneOf" ]:
344
- if keyword in group :
345
- for i , kw_content in enumerate (group [keyword ]):
346
- if "required" in kw_content :
347
- schema_no_required [self .defs_notation ][group_key ][keyword ][i ].pop ("required" )
348
- schema_no_required [self .defs_notation ][group_key ][keyword ] = [
349
- kw_content for kw_content in group [keyword ] if kw_content
350
- ]
351
- if not group [keyword ]:
352
- schema_no_required [self .defs_notation ][group_key ].pop (keyword )
353
- jsonschema .validate (self .schema_defaults , schema_no_required )
325
+ jsonschema .validate (self .schema_defaults , strip_required (self .schema ))
354
326
except jsonschema .exceptions .ValidationError as e :
355
327
log .debug (f"Complete error message:\n { e } " )
356
328
raise AssertionError (f"Default parameters are invalid: { e .message } " )
@@ -366,7 +338,7 @@ def validate_default_params(self):
366
338
self .get_wf_params ()
367
339
368
340
# Go over group keys
369
- for group_key , group in schema_no_required .get (self .defs_notation , {}).items ():
341
+ for group_key , group in self . schema .get (self .defs_notation , {}).items ():
370
342
group_properties = group .get ("properties" )
371
343
for param in group_properties :
372
344
if param in self .ignored_params :
@@ -1042,3 +1014,17 @@ def get_web_builder_response(self):
1042
1014
f"Pipeline schema builder returned unexpected status ({ web_response ['status' ]} ): "
1043
1015
f"{ self .web_schema_build_api_url } \n See verbose log for full response"
1044
1016
)
1017
+
1018
+
1019
+ def strip_required (node ):
1020
+ if isinstance (node , dict ):
1021
+ return {
1022
+ k : y
1023
+ for k , v in node .items ()
1024
+ for y in [strip_required (v )]
1025
+ if k != "required" and (y or y is False or y == "" )
1026
+ }
1027
+ elif isinstance (node , list ):
1028
+ return [y for v in node for y in [strip_required (v )] if y or y is False or y == "" ]
1029
+ else :
1030
+ return node
0 commit comments