@@ -3,7 +3,7 @@ use std::collections::{HashMap, HashSet};
3
3
use anyhow:: anyhow;
4
4
use async_nats:: { jetstream:: stream:: Stream , Client , Message } ;
5
5
use base64:: { engine:: general_purpose:: STANDARD as B64decoder , Engine } ;
6
- use jsonschema:: { Draft , JSONSchema } ;
6
+ use jsonschema:: { paths :: PathChunk , Draft , JSONSchema } ;
7
7
use regex:: Regex ;
8
8
use serde_json:: json;
9
9
use tokio:: sync:: OnceCell ;
@@ -952,14 +952,26 @@ pub(crate) async fn validate_manifest(manifest: Manifest) -> anyhow::Result<()>
952
952
if let Err ( errors) = validation_result {
953
953
let mut error_message = String :: new ( ) ;
954
954
for error in errors {
955
+ let instance_path = error
956
+ . instance_path
957
+ . into_iter ( )
958
+ . map ( |item| match item {
959
+ PathChunk :: Property ( value) => value. to_string ( ) ,
960
+ PathChunk :: Index ( idx) => format ! ( " at index: {idx}" ) ,
961
+ PathChunk :: Keyword ( keyword) => keyword. to_string ( ) ,
962
+ } )
963
+ . collect :: < Vec < String > > ( )
964
+ . join ( "/" ) ;
955
965
error_message. push_str ( & format ! (
956
- "Validation error in object: {} \n Object path: {}" ,
957
- // Error instance in the JSON instance and its corresponding path in that file
958
- error. instance,
959
- error. instance_path
966
+ "Should be able to parse object at: {} \n " ,
967
+ // The path of the corresponding JSON error instance in that file
968
+ instance_path
960
969
) ) ;
961
970
}
962
- return Err ( anyhow ! ( "Validation Error : \n {}" , error_message) ) ;
971
+ return Err ( anyhow ! (
972
+ "Validation Error: \n {}Please check for missing or incorrect elements" ,
973
+ error_message
974
+ ) ) ;
963
975
}
964
976
965
977
// Map of link names to a vector of provider references with that link name
@@ -1122,7 +1134,7 @@ mod test {
1122
1134
assert ! ( e
1123
1135
. to_string( )
1124
1136
// The 0th component in the spec list is incorrect and should be detected (indexing starts from 0)
1125
- . contains( "Object path: / spec/components/0" ) )
1137
+ . contains( "Should be able to parse object at: spec/components/ at index: 0" ) )
1126
1138
}
1127
1139
}
1128
1140
0 commit comments