Skip to content

Problem validating pattern properties #782

@tvahrst

Description

@tvahrst

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();
    }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions