-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Clarification on pattern regex literals #1985
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
Comments
@ricellis it is definitely 1. This should really be filed on the JSON Schema spec repo. I'll try to remember to clarify that i |
Thanks @handrews, I've opened json-schema-org/json-schema-spec#774 for a clarification in the JSON Schema validation spec. I guess there may still be work here to update the link in the OAS spec or also cite that only a |
Note that the JSON Schema spec has been updated (targetting draft-08) to clarify this via json-schema-org/json-schema-spec#775. As per that clarification; the correct ECMA 262 section to link is 15.10.1 - I've opened PR #1987 to correct the OpenAPI spec link to also point to that section. |
JSON Schema 2019-09 (formerly known as "draft-08") has been published, and OAS PR #1977 is about updating the Schema Object to be compatible with it in OAS 3.1. I think the PR mentioned above is still useful for OAS 3.0, as the JSON Schema draft there will not be changing. |
This was fixed in #1977 so we can close this. |
The specification for pattern says
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 docI 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
The text was updated successfully, but these errors were encountered: