daveshanley / vacuum

vacuum is the worlds fastest OpenAPI 3, OpenAPI 2 / Swagger linter and quality analysis tool. Built in go, it tears through API specs faster than you can think. vacuum is compatible with Spectral rulesets and generates compatible reports.
https://quobix.com/vacuum
MIT License
577 stars 48 forks source link

Java regex support #503

Closed pdurbin closed 4 months ago

pdurbin commented 4 months ago

Hi! I'm playing around with vacuum, feeding it an OpenAPI doc generated from Java using SmallRye.

I'm getting this error...

schema `pattern` should be a ECMA-262 regular expression dialect

...on a regular expression that works fine in Java (more context): "^[^:<>;#/\"\\*\\|\\?\\\\]*$"

When I print the err in vacuum, it says this:

SyntaxError: Unterminated character class at <eval>:1:15(3)

Apologies if I'm barking up the wrong tree with this error! Vacuum seems great!

daveshanley commented 4 months ago

Hi There,

The regular expressions supported by vacuum are ECMA-262 compatible only. This is because we use a built in JavaScript engine to compile the regular expression. If it fails - the pattern is no good and does not conform to the standard.

The standard for patterns is a part of the JSON Schema standard.

https://json-schema.org/understanding-json-schema/reference/regular_expressions

The regular expression syntax used is from JavaScript ([ECMA 262](https://www.ecma-international.org/publications-and-standards/standards/ecma-262/), specifically).

Any other dialect of regex is going to fail, because technically... it should :)

Thanks for using vacuum.