-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
version/3.0: Add a 'duration' format #359
Comments
We only create stops at verification time, but folks will want to have estimated delivery times while they're shopping for their order. David confirmed that a single model should store the usual offset between the start of delivery and a given drop on a route, so we need to expose that data publically. This commit specifies that API and adjusts the stop description to explain that it's only useful for verified trips. The duration format specifies ISO 8601 durations [1,2]. I've proposed it for inclusion in future versions of Swagger [3], but until that's accepted we're using it as a custom format [4]. [1]: https://tools.ietf.org/html/rfc3339#page-13 [2]: http://en.wikipedia.org/wiki/ISO_8601#Durations [3]: OAI/OpenAPI-Specification#359 [4]: https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#data-types Swagger uses several known formats to more finely define the data type being used. However, the format property is an open string-valued property, and can have any value to support documentation needs. Formats such as "email", "uuid", etc., can be used even though they are not defined by this specification.
Would be useful for OData and its Duration primitive type which uses xsd:dayTimeDuration format |
Tackling PR: #741 |
Will be tackled in #845 instead. |
Closing as all tickets will be tackled there. |
Reviving an old thread here, wanting to tackle a bunch of issues within the same ticket is fine, but reading through that long ticket gave me no clue at to what the conclusion was, or how to use ISO 8601 durations in my OpenAPI document... |
Sorry, in a bit of a rush, but basically:
|
Wonderful :) Even better than something OpenAPI-specific. |
Thanks, does OpenAPI already support JSONSchema's Draft 2019-09? If so from what version? Meaning can I expect implementations of OAS to support |
OAS 3.1 (in RC stage) supports JSON Schema draft 2019-09, 3.1 final should hopefully support JSON Schema draft 2020-XX (which is as-yet unpublished). There is a wrinkle, in that JSON Schema 2019+ defines You can use |
@nasht00 note that the "not a validation assertion by default" is due to The expectation is that the new modular extension vocabulary support will result in well-defined validation keywords being created that don't staple completely unrelated concepts together. A date and time vocabulary with well-defined validation keywords would be very easy to add, as those concepts have very clear specifications from IETF and/or ISO. |
Spun off from #356 to avoid PRs which don't attract comments ;).
On IRC today, Tony Tam pointed out that folks currently work around
the lack of durations by using an int64 for millisecond offsets, but
that's not very human readable. And we care about human-readability
or we'd all be using protobufs instead of JSON, right? ;).
The support for ISO 8601 durations in native JavaScript is
unclear, but both Firefox 31.5 and Chromium 41.0 give:
So the millisecond approach may be easier to use in JavaScript
applications, where date-times are stored as millisecond offsets from
the epoch, you can instantiate Dates from those millisecond
offsets, and durations are in milliseconds by default.
The Moment.js library supports durations based on millisecond offsets:
explicit units:
and
[{day}.]{hour}:{minute}[:{second}[.{fraction}]]
strings:And it renders ISO 8601 durations, but it
doesn't appear to parse that format.
Java parses ISO 8601 durations with an extension to support negative
durations.
Go parses durations from its own format.
Python has a duration type, but does not parse ISO 8601 durations.
The text was updated successfully, but these errors were encountered: