@@ -137,7 +137,34 @@ switch ($command) {
137
137
}
138
138
if (!$ validator ->isValid ()) {
139
139
print_formatted ("\BOpenAPI v3.0 schema violations:\C \n" , STDERR );
140
- foreach ($ validator ->getErrors () as $ error ) {
140
+ $ errors = $ validator ->getErrors ();
141
+ foreach ($ errors as $ error ) {
142
+ // hide some errors triggered by other errors further down the path
143
+ if (strpos ($ error ['message ' ], 'The property $ref is required ' ) !== false && substr ($ error ['property ' ], -4 , 4 ) === '$ref ' ) {
144
+ $ hasErrorInPath = false ;
145
+ foreach ($ errors as $ suberror ) {
146
+ if ($ suberror ['property ' ] !== $ error ['property ' ] && strpos ($ suberror ['property ' ], substr ($ error ['property ' ], 0 , -4 )) === 0 ) {
147
+ $ hasErrorInPath = true ;
148
+ break ;
149
+ }
150
+ }
151
+ if ($ hasErrorInPath ) {
152
+ continue ;
153
+ }
154
+ }
155
+ if (strpos ($ error ['message ' ], 'Failed to match exactly one schema ' ) !== false ) {
156
+ $ hasErrorInPath = false ;
157
+ foreach ($ errors as $ suberror ) {
158
+ if (strpos ($ suberror ['property ' ], $ error ['property ' ] . '. ' ) === 0 ) {
159
+ $ hasErrorInPath = true ;
160
+ break ;
161
+ }
162
+ }
163
+ if ($ hasErrorInPath ) {
164
+ continue ;
165
+ }
166
+ }
167
+
141
168
print_formatted (sprintf ("- [\Y%s\C] %s \n" , escape_formatted ($ error ['property ' ]), escape_formatted ($ error ['message ' ])), STDERR );
142
169
}
143
170
}
@@ -306,7 +333,7 @@ function print_formatted($string, $stream) {
306
333
fwrite ($ stream , strtr ($ string , [
307
334
'\\Y ' => "\033[33m " , // yellow
308
335
'\\G ' => "\033[32m " , // green
309
- '\\R ' => "\033[31m " , // green
336
+ '\\R ' => "\033[31m " , // red
310
337
'\\B ' => "\033[1m " , // bold
311
338
'\\C ' => "\033[0m " , // clear
312
339
'\\\\' => '\\' ,
0 commit comments