in oas-validator/oas-validator-core/src/main/java/org/apache/servicecomb/toolkit/oasv/diffvalidation/util/OasObjectDiffValidatorUtils.java [186:239]
public static <T> List<OasDiffViolation> doDiffValidateMapProperty(
OasDiffValidationContext context,
String mapPropertyName,
OasObjectPropertyLocation leftOwnerLocation,
Map<String, T> leftMapProperty,
OasObjectPropertyLocation rightOwnerLocation,
Map<String, T> rightMapProperty,
OasObjectType valueType,
List<? extends OasObjectDiffValidator<T>> validators
) {
assertOwnerLocationNotNull(leftOwnerLocation, rightOwnerLocation);
if (leftMapProperty == null) {
leftMapProperty = emptyMap();
}
if (rightMapProperty == null) {
rightMapProperty = emptyMap();
}
List<OasDiffViolation> violations = new ArrayList<>();
for (Map.Entry<String, T> entry : leftMapProperty.entrySet()) {
String leftKey = entry.getKey();
T leftValue = entry.getValue();
String keyName = mapPropertyName + ".'" + leftKey + "'";
OasObjectPropertyLocation leftValueLoc = leftOwnerLocation.property(keyName, valueType);
T rightValue = rightMapProperty.get(leftKey);
if (rightValue == null) {
violations.addAll(doDiffValidateProperty(context, leftValueLoc, leftValue, null, null, validators));
} else {
OasObjectPropertyLocation rightValueLoc = rightOwnerLocation.property(keyName, valueType);
violations
.addAll(doDiffValidateProperty(context, leftValueLoc, leftValue, rightValueLoc, rightValue, validators));
}
}
for (Map.Entry<String, T> entry : rightMapProperty.entrySet()) {
String rightKey = entry.getKey();
if (leftMapProperty.containsKey(rightKey)) {
continue;
}
T rightValue = entry.getValue();
String keyName = mapPropertyName + ".'" + rightKey + "'";
OasObjectPropertyLocation rightLoc = rightOwnerLocation.property(keyName, valueType);
violations.addAll(doDiffValidateProperty(context, null, null, rightLoc, rightValue, validators));
}
return violations;
}