-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Description
The specification for pattern says
This string SHOULD be a valid regular expression, according to the ECMA 262 regular expression dialect
I think this is extracted verbatim from the JSON Schema validation draft as per #880
However, the section of ECMA262 linked to describes the regular expression literal i.e. / RegularExpressionBody / RegularExpressionFlags
so it is unclear whether "valid regular expression" means the body or the literal.
There are no example usages of regex patterns in the OAS 3.0.2 document that I can see. However, another example of patterns used in OpenAPI that I have found does not include the /
characters around the regex e.g.:
pattern: '^\d{3}-\d{2}-\d{4}$'
from swagger doc
I think it is unclear from the specification (either OAS or JSON schema validation) whether the pattern field is expected to be a complete ECMA 262 regular expression literal, including the /
characters and optionally including flags, or whether it is saying that only a regular expression body is expected.
Tooling behaviour seems a little inconsistent on this too, so I think a clarification would be useful to help tooling developers know which of these 3 types of pattern values should be supported:
myregexbody
/myregexbody/
/myregexbody/myregexflags