@@ -387,6 +387,39 @@ impl<F: FnMut(Change)> DiffWalker<F> {
387387 }
388388 }
389389
390+ fn diff_enum ( & mut self , json_path : & str , lhs : & mut SchemaObject , rhs : & mut SchemaObject ) {
391+ let lhs_enum = lhs. enum_values . as_deref ( ) . unwrap_or ( & [ ] ) ;
392+ let rhs_enum = rhs. enum_values . as_deref ( ) . unwrap_or ( & [ ] ) ;
393+ let lhs_has_no_enum = lhs. enum_values . is_none ( ) ;
394+ let rhs_has_no_enum = rhs. enum_values . is_none ( ) ;
395+
396+ // Find removed enum values (in lhs but not in rhs)
397+ for lhs_value in lhs_enum {
398+ if !rhs_enum. contains ( lhs_value) {
399+ ( self . cb ) ( Change {
400+ path : json_path. to_owned ( ) ,
401+ change : ChangeKind :: EnumRemove {
402+ removed : lhs_value. clone ( ) ,
403+ rhs_has_no_enum,
404+ } ,
405+ } ) ;
406+ }
407+ }
408+
409+ // Find added enum values (in rhs but not in lhs)
410+ for rhs_value in rhs_enum {
411+ if !lhs_enum. contains ( rhs_value) {
412+ ( self . cb ) ( Change {
413+ path : json_path. to_owned ( ) ,
414+ change : ChangeKind :: EnumAdd {
415+ added : rhs_value. clone ( ) ,
416+ lhs_has_no_enum,
417+ } ,
418+ } ) ;
419+ }
420+ }
421+ }
422+
390423 fn diff_pattern ( & mut self , json_path : & str , lhs : & mut SchemaObject , rhs : & mut SchemaObject ) {
391424 let lhs_pattern = & lhs. string ( ) . pattern ;
392425 let rhs_pattern = & rhs. string ( ) . pattern ;
@@ -594,6 +627,7 @@ impl<F: FnMut(Change)> DiffWalker<F> {
594627 }
595628 self . diff_const ( json_path, lhs, rhs) ;
596629 self . diff_format ( json_path, lhs, rhs) ;
630+ self . diff_enum ( json_path, lhs, rhs) ;
597631 self . diff_pattern ( json_path, lhs, rhs) ;
598632 self . diff_min_length ( json_path, lhs, rhs) ;
599633 self . diff_max_length ( json_path, lhs, rhs) ;
0 commit comments