@@ -694,12 +694,9 @@ function validate(
694694 }
695695 }
696696
697- const testAlternatives = ( alternatives : JSONSchemaRef [ ] , minOneMatch : boolean ) : number => {
697+ const testAlternatives = ( alternatives : JSONSchemaRef [ ] , maxOneMatch : boolean ) : number => {
698698 const matches = [ ] ;
699- let minMatch = 1 ;
700- if ( minOneMatch ) {
701- minMatch = alternatives . length ;
702- }
699+ const noPropertyMatches = [ ] ;
703700 // remember the best match that is used for error messages
704701 let bestMatch : {
705702 schema : JSONSchema ;
@@ -713,6 +710,9 @@ function validate(
713710 validate ( node , subSchema , schema , subValidationResult , subMatchingSchemas , options ) ;
714711 if ( ! subValidationResult . hasProblems ( ) ) {
715712 matches . push ( subSchema ) ;
713+ if ( subValidationResult . propertiesMatches === 0 ) {
714+ noPropertyMatches . push ( subSchema ) ;
715+ }
716716 }
717717 if ( ! bestMatch ) {
718718 bestMatch = {
@@ -723,11 +723,11 @@ function validate(
723723 } else if ( isKubernetes ) {
724724 bestMatch = alternativeComparison ( subValidationResult , bestMatch , subSchema , subMatchingSchemas ) ;
725725 } else {
726- bestMatch = genericComparison ( minOneMatch , subValidationResult , bestMatch , subSchema , subMatchingSchemas ) ;
726+ bestMatch = genericComparison ( maxOneMatch , subValidationResult , bestMatch , subSchema , subMatchingSchemas ) ;
727727 }
728728 }
729729
730- if ( matches . length > minMatch && minOneMatch ) {
730+ if ( matches . length > 1 && noPropertyMatches . length === 0 && maxOneMatch ) {
731731 validationResult . problems . push ( {
732732 location : { offset : node . offset , length : 1 } ,
733733 severity : DiagnosticSeverity . Warning ,
0 commit comments