-
Notifications
You must be signed in to change notification settings - Fork 9.1k
write out the date-time pattern #2374
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
Not everything can be expressed as a regular expression. The date-time format ultimately comes from JSON Schema -- https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.7.3.1 |
How should I validate date-time values? It seems the only reason to set a format of date-time was to avoid the hassle of putting in the regex. If its not a regular grammar, then what's the point of specifying a format? |
@delanym How to validate date-time format is not part of the OpenAPI specification, but it is specified in the JSON Schema specification (see link posted by @karenetheridge or here). Relying on standard JSON Schema is good, because if you are building a tool on top of OAS, you can use any standards compliant JSON Schema library to handle validation. 🚀 This even got simpler in OAS 3.1. |
How did it get simpler in OAS 3.1? |
@delanym Whereas before OAS used it's own flavour of JSON Schema that diverged in quite a lot of cases, OAS 3.1 (RC) uses standard JSON Schema (plus a hand full of additional keywords). |
Closing as answered. Thanks all. |
What exactly is the regex matching pattern for date-time?
The specification simply points to the RFC3339 page. Its not obvious from reading this page how to validate these fields. The page defers to a further ISO standard, it uses a non-machine readable ABNF notation, and it includes extra exceptions.
https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14
The text was updated successfully, but these errors were encountered: