@@ -999,6 +999,12 @@ fn from_integration_json_v2(
999999 let matching_rules = rules. add_category ( category) ;
10001000 let path_or_status = [ Category :: PATH , Category :: STATUS ] . contains ( & matching_rules. name ) ;
10011001 let query_or_header = [ Category :: QUERY , Category :: HEADER ] . contains ( & matching_rules. name ) ;
1002+ // Compute the effective generator/rule path once: for PATH/STATUS, use the parent path
1003+ let effective_path = if path_or_status {
1004+ path. parent ( ) . unwrap_or ( DocPath :: root ( ) )
1005+ } else {
1006+ path. clone ( )
1007+ } ;
10021008
10031009 match serde_json:: from_str ( value) {
10041010 Ok ( json) => match & json {
@@ -1059,12 +1065,7 @@ fn from_integration_json_v2(
10591065 debug ! ( "detected pact:generator:type, will configure a generators" ) ;
10601066 if let Some ( generator) = Generator :: from_map ( & json_to_string ( gen) , map) {
10611067 let category = generator_category ( matching_rules) ;
1062- let path = if path_or_status {
1063- path. parent ( ) . unwrap_or ( DocPath :: root ( ) )
1064- } else {
1065- path. clone ( )
1066- } ;
1067- generators. add_generator_with_subcategory ( category, path. clone ( ) , generator) ;
1068+ generators. add_generator_with_subcategory ( category, effective_path. clone ( ) , generator) ;
10681069 }
10691070 }
10701071
@@ -1073,12 +1074,7 @@ fn from_integration_json_v2(
10731074 debug ! ( "detected 'expression' without 'pact:matcher:type', configuring ProviderStateGenerator" ) ;
10741075 if let Some ( generator) = Generator :: from_map ( "ProviderState" , map) {
10751076 let category = generator_category ( matching_rules) ;
1076- let gen_path = if path_or_status {
1077- path. parent ( ) . unwrap_or ( DocPath :: root ( ) )
1078- } else {
1079- path. clone ( )
1080- } ;
1081- generators. add_generator_with_subcategory ( category, gen_path, generator) ;
1077+ generators. add_generator_with_subcategory ( category, effective_path. clone ( ) , generator) ;
10821078 }
10831079 map. get ( "value" ) . cloned ( ) . unwrap_or_default ( )
10841080 } else {
0 commit comments