-
Notifications
You must be signed in to change notification settings - Fork 29
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
String format/pattern recommendation #330
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: Eric Murray <[email protected]>
On general level it is covered as duration is listed in the registry: The open question is whether it should be mandated to use strings for duration or leave the decision to subprojects (to use integers or object types). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I agree with @rartych that we still have an open question regarding whether we require duration to be always expressed and formatted as "format: duration", or whether we just allow subprojects to adopt this format, and in this case we recommend to add explicitly the My feeling is that we still don't have enough consensus in issue #137 to require all APIs to adopt RFC 3339 format for next meta, as that measure would impact many APIs, breaking backward compatibility. |
After review I agree with that. From some documentation found in "open internet" ISO 8601 indicates for duration. So as initially using RFC3339 as a reference would fit in our purposes but let's see within Issue #137
When an application identifies the need for a complete representation of a time interval through its duration and context information, with duration in the format with designators, it shall use an expression in accordance with 4.4.2 using a complete duration representation as defined in 4.4.3.2.
Basic and extended format: PnnYnnMnnDTnnHnnMnnS
PnnW
Example 1: P2Y10M15DT10H30M20S
Example 2: P6W RFC 3339
|
@@ -1337,14 +1337,15 @@ This part describes the list of possible messages returned by the API. It also i | |||
This part captures a detailed description of all the data structures used in the API specification. For each of these data, the specification must contain: | |||
- Name of the data object, used to reference it in other sections. | |||
- Data type (String, Integer, Object…). | |||
- If the format of a string is date-time following sentence must be present in the description: `It must follow [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) and must have time zone. Recommended format is yyyy-MM-dd'T'HH:mm:ss.SSSZ (i.e. which allows 2023-07-03T14:27:08.312+02:00 or 2023-07-03T12:27:08.312Z)` | |||
- If the data type is string it is recommended to use appropriate modifier property `format` and/or `pattern` whenever possible. The [OpenAPI Initiative Formats Registry](https://spec.openapis.org/registry/format/) contains the list of formats used in OpenAPI specifications. | |||
- If the format of a string is `date-time`, the following sentence must be present in the description: `It must follow [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) and must have time zone. Recommended format is yyyy-MM-dd'T'HH:mm:ss.SSSZ (i.e. which allows 2023-07-03T14:27:08.312+02:00 or 2023-07-03T12:27:08.312Z)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is inherited from the current text, but ISO 8601 defines date format as YYYY-MM-DD. RFC 3339 expresses formats in ABNF, so does not define an equivalent formatting string, but YYYY-MM-DD is not wrong for RFC 3339.
- If the format of a string is `date-time`, the following sentence must be present in the description: `It must follow [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) and must have time zone. Recommended format is yyyy-MM-dd'T'HH:mm:ss.SSSZ (i.e. which allows 2023-07-03T14:27:08.312+02:00 or 2023-07-03T12:27:08.312Z)` | |
- If the format of a string is `date-time`, the following sentence must be present in the description: `It must follow [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) and must have time zone. Recommended format is YYYY-MM-DD'T'HH:mm:ss.SSSZ (i.e. which allows 2023-07-03T14:27:08.312+02:00 or 2023-07-03T12:27:08.312Z)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yyyy-MM-dd'T'HH:mm:ss.SSSZ
template is typical for java, so it is somehow developer friendly.
As the change would require updating OAS using date-time
I would prefer to keep it as it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I didn't realise this was a Java notation. As far as I can tell, whether the letter placeholder is upper or lower case makes no difference to the allowed values. Adding a reference to the Java definition at some point in the future might help interpret this string.
As format: date
is used by some APIs, I will add a line for that as well.
@@ -1337,14 +1337,15 @@ This part describes the list of possible messages returned by the API. It also i | |||
This part captures a detailed description of all the data structures used in the API specification. For each of these data, the specification must contain: | |||
- Name of the data object, used to reference it in other sections. | |||
- Data type (String, Integer, Object…). | |||
- If the format of a string is date-time following sentence must be present in the description: `It must follow [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) and must have time zone. Recommended format is yyyy-MM-dd'T'HH:mm:ss.SSSZ (i.e. which allows 2023-07-03T14:27:08.312+02:00 or 2023-07-03T12:27:08.312Z)` | |||
- If the data type is string it is recommended to use appropriate modifier property `format` and/or `pattern` whenever possible. The [OpenAPI Initiative Formats Registry](https://spec.openapis.org/registry/format/) contains the list of formats used in OpenAPI specifications. | |||
- If the format of a string is `date-time`, the following sentence must be present in the description: `It must follow [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) and must have time zone. Recommended format is yyyy-MM-dd'T'HH:mm:ss.SSSZ (i.e. which allows 2023-07-03T14:27:08.312+02:00 or 2023-07-03T12:27:08.312Z)` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- If the format of a string is `date-time`, the following sentence must be present in the description: `It must follow [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) and must have time zone. Recommended format is yyyy-MM-dd'T'HH:mm:ss.SSSZ (i.e. which allows 2023-07-03T14:27:08.312+02:00 or 2023-07-03T12:27:08.312Z)` | |
- If the format of a string is `date-time`, the following sentence MUST be present in the description: `It must follow [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6) and must have time zone. Recommended format is yyyy-MM-dd'T'HH:mm:ss.SSSZ (i.e. which allows 2023-07-03T14:27:08.312+02:00 or 2023-07-03T12:27:08.312Z)` | |
- If the format of a string is `date`, a statement MUST be included in the description that the date be specified using the RFC 3339 / ISO 8601 compliant format YYYY-MM-DD |
What type of PR is this?
What this PR does / why we need it:
Using string format or pattern modifiers simplify implementation and clarify parameter usage.
Recommendation added to section 11.5 Data Definitions.
Which issue(s) this PR fixes:
Fixes #93
Does this PR introduce a breaking change?
Special notes for reviewers:
Changelog input
Additional documentation
https://spec.openapis.org/oas/v3.0.3.html#data-types