Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] Exclude violation operation.notAllowed with 405 #43

Merged
merged 9 commits into from
Oct 18, 2023

Conversation

pboos
Copy link
Collaborator

@pboos pboos commented Oct 17, 2023

When there is a validation.request.operation.notAllowed violation and the response already is 405 (Method Not Allowed) then this should not be reported as a violation.

Reason: The API responds correctly that this method is not allowed. There is nothing to be fixed in the API nor the spec.

@pboos pboos requested a review from a team as a code owner October 17, 2023 09:38
@pboos pboos requested a review from huguenin October 17, 2023 09:38

private boolean falsePositive405(OpenApiViolation violation) {
return violation.getResponseStatus().orElse(0) == 405
&& "validation.request.operation.notAllowed".equals(violation.getRule());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the rule name here go into a constant? Are all rules defined somewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not defined anywhere in swagger-request-validator. I have now extracted them here in the file at least.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will create a const file now as we also use them in other places.

Copy link
Member

@huguenin huguenin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good, just a formality. Also, there are tons of changes that seem unrelated to the fix - I didn't check those in detail. Would recommend not including these in the future, or creating a separate PR.

@pboos pboos merged commit 6176fd2 into main Oct 18, 2023
1 check passed
@pboos pboos deleted the bugfix/exclude-correct-405-violations branch October 18, 2023 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants