Skip to content

Commit a824063

Browse files
committed
extract method
1 parent 8e6d120 commit a824063

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

openapi-validation-core/src/main/java/com/getyourguide/openapi/validation/core/OpenApiRequestValidator.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public List<OpenApiViolation> validateRequestObject(
9999
var result = validator.validateRequest(simpleRequest);
100100
var violations = mapper.map(result, request, response, Direction.REQUEST, requestBody);
101101
return violations.stream()
102-
.filter(violation -> !LogLevel.IGNORE.equals(violation.getLevel()) && !violationExclusions.isExcluded(violation))
102+
.filter(this::isNonExcludedViolation)
103103
.toList();
104104
} catch (Exception e) {
105105
log.error("[OpenAPI Validation] Could not validate request", e);
@@ -146,11 +146,15 @@ public List<OpenApiViolation> validateResponseObject(
146146
);
147147
var violations = mapper.map(result, request, response, Direction.RESPONSE, responseBody);
148148
return violations.stream()
149-
.filter(violation -> !LogLevel.IGNORE.equals(violation.getLevel()) && !violationExclusions.isExcluded(violation))
149+
.filter(this::isNonExcludedViolation)
150150
.toList();
151151
} catch (Exception e) {
152152
log.error("[OpenAPI Validation] Could not validate response", e);
153153
return List.of();
154154
}
155155
}
156+
157+
private boolean isNonExcludedViolation(OpenApiViolation violation) {
158+
return !LogLevel.IGNORE.equals(violation.getLevel()) && !violationExclusions.isExcluded(violation);
159+
}
156160
}

0 commit comments

Comments
 (0)