Skip to content

bugfix: Exclude "matched 2 out of 25" in the oneOf rule - #36

Merged
pboos merged 4 commits into
mainfrom
bugfix/oneOf-exclusion-not-working-with-of-xx
Aug 30, 2023
Merged

bugfix: Exclude "matched 2 out of 25" in the oneOf rule#36
pboos merged 4 commits into
mainfrom
bugfix/oneOf-exclusion-not-working-with-of-xx

Conversation

@pboos

@pboos pboos commented Aug 30, 2023

Copy link
Copy Markdown
Contributor

A violation like the following should have been excluded, but was not:

OpenAPI spec validation error [validation.response.body.schema.oneOf]
...

INFO - [Path '/.../0'] Instance failed to match exactly one schema (matched 2 out of 25): 
...

Bug: It only worked if matched 2 out of x with x being a single number.

This is fixed with this PR switching from just \d to \d+.

@pboos
pboos requested review from a team and dominik-riha August 30, 2023 09:29
Comment on lines +20 to +25
return (
"validation.response.body.schema.oneOf".equals(violation.getRule())
|| "validation.request.body.schema.oneOf".equals(violation.getRule())
)
&& violation.getMessage()
.matches(".*Instance failed to match exactly one schema \\(matched [1-9][0-9]* out of \\d+\\).*");

@pboos pboos Aug 30, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ I decided to also add the rules, to be safe.

@eleonoraborghi eleonoraborghi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🏅

@pboos
pboos merged commit ff2e60a into main Aug 30, 2023
@pboos
pboos deleted the bugfix/oneOf-exclusion-not-working-with-of-xx branch August 30, 2023 11:38
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