@@ -260,6 +260,36 @@ impl DiffWalker {
260260 Ok ( ( ) )
261261 }
262262
263+ fn diff_required (
264+ & mut self ,
265+ json_path : & str ,
266+ lhs : & mut SchemaObject ,
267+ rhs : & mut SchemaObject ,
268+ ) -> Result < ( ) , Error > {
269+ let lhs_required = & lhs. object ( ) . required ;
270+ let rhs_required = & rhs. object ( ) . required ;
271+
272+ for removed in lhs_required. difference ( rhs_required) {
273+ self . changes . push ( Change {
274+ path : json_path. to_owned ( ) ,
275+ change : ChangeKind :: RequiredRemove {
276+ property : removed. clone ( ) ,
277+ } ,
278+ } ) ;
279+ }
280+
281+ for added in rhs_required. difference ( lhs_required) {
282+ self . changes . push ( Change {
283+ path : json_path. to_owned ( ) ,
284+ change : ChangeKind :: RequiredAdd {
285+ property : added. clone ( ) ,
286+ } ,
287+ } ) ;
288+ }
289+
290+ Ok ( ( ) )
291+ }
292+
263293 fn resolve_ref < ' a > ( root_schema : & ' a RootSchema , reference : & str ) -> Option < & ' a Schema > {
264294 if let Some ( definition_name) = reference. strip_prefix ( "#/definitions/" ) {
265295 let schema_object = root_schema. definitions . get ( definition_name) ?;
@@ -302,6 +332,7 @@ impl DiffWalker {
302332 self . diff_range ( json_path, lhs, rhs) ?;
303333 self . diff_additional_properties ( json_path, lhs, rhs) ?;
304334 self . diff_array_items ( json_path, lhs, rhs) ?;
335+ self . diff_required ( json_path, lhs, rhs) ?;
305336 Ok ( ( ) )
306337 }
307338}
0 commit comments