Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public static class Request {

public static class Response {
public static final String BODY_SCHEMA_ONE_OF = "validation.response.body.schema.oneOf";
public static final String STATUS_UNKNOWN = "validation.response.status.unknown";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public boolean isExcluded(OpenApiViolation violation) {
return falsePositive404(violation)
|| falsePositive400(violation)
|| falsePositive405(violation)
|| falsePositive406(violation)
|| customViolationExclusions.isExcluded(violation)
|| oneOfMatchesMoreThanOneSchema(violation);
}
Expand Down Expand Up @@ -47,4 +48,9 @@ private boolean falsePositive405(OpenApiViolation violation) {
return violation.getResponseStatus().orElse(0) == 405
&& Rules.Request.OPERATION_NOT_ALLOWED.equals(violation.getRule());
}

private boolean falsePositive406(OpenApiViolation violation) {
return violation.getResponseStatus().orElse(0) == 406
&& Rules.Response.STATUS_UNKNOWN.equals(violation.getRule());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,18 @@ public void when405ResponseCodeWithOperationNotAllowedViolationThenViolationExcl
.build());
}

@Test
public void when406ResponseCodeWithStatusUnknownViolationThenViolationExcluded() {
when(customViolationExclusions.isExcluded(any())).thenReturn(false);

checkViolationExcluded(OpenApiViolation.builder()
.direction(Direction.RESPONSE)
.rule("validation.response.status.unknown")
.responseStatus(406)
.message("")
.build());
}

private void checkViolationNotExcluded(OpenApiViolation violation) {
var isExcluded = violationExclusions.isExcluded(violation);

Expand Down