@@ -278,6 +278,9 @@ class ReferenceValidator:
278278 skip_normalization : bool = None
279279 """If True, then only perform validation, not normalization"""
280280
281+ expand_all : bool = None
282+ """If True, then expand all SimpleDict and CompactDict objects to ExpandedDicts"""
283+
281284 def __post_init__ (self ):
282285 self .derived_schema = self .schemaview .materialize_derived_schema ()
283286
@@ -416,6 +419,8 @@ def infer_slot_collection_form(self, parent_slot: SlotDefinition) -> CollectionF
416419 return CollectionForm .List
417420 if parent_slot .inlined_as_list :
418421 return CollectionForm .List
422+ if self .expand_all :
423+ return CollectionForm .ExpandedDict
419424 simple_dict_value_slot = self ._slot_as_simple_dict_value_slot (parent_slot )
420425 if simple_dict_value_slot :
421426 return CollectionForm .SimpleDict
@@ -1000,12 +1005,18 @@ def _matches_slot_expression(
10001005
10011006
10021007@click .command
1003- @click .option ("--schema" , "-s" , required = True )
1004- @click .option ("--target" , "-C" )
1005- @click .option ("--report-file" , "-R" , type = click .File ("w" ), default = sys .stderr )
1008+ @click .option ("--schema" , "-s" , required = True ,
1009+ help = "Path to LinkML schema" )
1010+ @click .option ("--target" , "-C" ,
1011+ help = "name of target class or element to normalize/validate against" )
1012+ @click .option ("--report-file" , "-R" , type = click .File ("w" ), default = sys .stderr ,
1013+ show_default = True ,
1014+ help = "path to file for reports" )
10061015@click .option ("--output" , "-o" , type = click .File ("w" ), default = sys .stdout )
1016+ @click .option ("--expand-all/--no-expand-all" ,
1017+ help = "If True, expand all Dicts to ExpandedDicts" )
10071018@click .argument ("input" )
1008- def cli (schema : str , target : str , input : str , report_file : TextIO , output : TextIO ) -> None :
1019+ def cli (schema : str , target : str , input : str , report_file : TextIO , output : TextIO , ** kwargs ) -> None :
10091020 """
10101021 Normalizes and validates a YAML document against a schema.
10111022
@@ -1026,7 +1037,7 @@ def cli(schema: str, target: str, input: str, report_file: TextIO, output: TextI
10261037 :return:
10271038 """
10281039 sv = SchemaView (schema )
1029- normalizer = ReferenceValidator (sv )
1040+ normalizer = ReferenceValidator (sv , ** kwargs )
10301041 with open (input ) as f :
10311042 input_object = yaml .safe_load (f )
10321043 report = Report ()
0 commit comments