Skip to content

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

Closed
delanym opened this issue Oct 14, 2020 · 6 comments
Closed

write out the date-time pattern #2374

delanym opened this issue Oct 14, 2020 · 6 comments

Comments

@delanym
Copy link

delanym commented Oct 14, 2020

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

@karenetheridge
Copy link
Member

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

@delanym
Copy link
Author

delanym commented Oct 15, 2020

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?

@ahx
Copy link

ahx commented Oct 15, 2020

@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.

@delanym
Copy link
Author

delanym commented Oct 15, 2020

How did it get simpler in OAS 3.1?

@ahx
Copy link

ahx commented Oct 15, 2020

@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).

@MikeRalphson
Copy link
Member

Closing as answered. Thanks all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants