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

Problem validating pattern properties #782

Closed
tvahrst opened this issue May 22, 2023 · 0 comments · Fixed by #783
Closed

Problem validating pattern properties #782

tvahrst opened this issue May 22, 2023 · 0 comments · Fixed by #783
Assignees

Comments

@tvahrst
Copy link

tvahrst commented May 22, 2023

With the new version 1.0.82 we got errors validating our openapi 3.0 documents. The reason is, that we use properties which a allowed by a patternproperties rule in the openapi spec:

  "patternProperties": {
    "^x-": {
    }

Our properties (e.g. x-api-id) are conform with the spec. But the new JDKRegularExpression class fails to validate our property.

The reason is that JDKRegularExpression uses Matcher.matches() to validate the input. This method returns true only if the whole string matches - the regex is treated by matches() Method as 'anchored regex'.

The json schema spec states:

A string instance is considered valid if the regular expression matches the instance successfully. Recall: regular expressions are not implicitly anchored.

I suggest to change JDKRegularExpression to:

    @Override
    public boolean matches(String value) {
        return this.pattern.matcher(value).find();
    }

@fdutton fdutton self-assigned this May 22, 2023
fdutton pushed a commit that referenced this issue May 22, 2023
@fdutton fdutton linked a pull request May 22, 2023 that will close this issue
fdutton pushed a commit that referenced this issue May 22, 2023
stevehu pushed a commit that referenced this issue May 23, 2023
* Resolves improper anchoring of patternProperties

Fixes #782

* Resolves improper anchoring of regular expressions in both Joni and JDK engines.

Resolves #495 and #782

---------

Co-authored-by: Faron Dutton <faron.dutton@insightglobal.com>
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 a pull request may close this issue.

2 participants