-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add support for "duration" string format. #117
Conversation
Thanks for the PR! This looks very good. We have also tests for duration in the test suite [1]. At the moment these tests are disabled, could you please remove related lines in this file [2] to activate the tests? [1] https://github.com/eclipse-vertx/vertx-json-schema/blob/master/src/test/resources/test-suite-tck.json |
@pk-work It's done. |
Where is the comment? I think the test suite we are using is the official one from JSON Schema. We should not change the tests, we should change the code that it fits to the tests. |
@@ -3784,7 +3784,7 @@ | |||
{ | |||
"description": "invalid duration string is only an annotation by default", | |||
"data": "PT1D", | |||
"valid": true | |||
"valid": false |
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.
@pk-work I had to change these test definition.
They were failling and they looked wrong to me as PT1D is not a valid duration in ISO 8601.
I let you confirm I'm not wrong.
Sorry, I forgot to publih my comment. |
Hello @pk-work, What's your feedback regarding my last comment? Best, |
@lcharlois-neotys Hi, unfortunately I was ill, but I will try to have a look on Friday. I need to understand it a little bit better, because I don't know yet if the test data is correct or not. |
Oh sorry, I was not sure if you have missed the comment or if you were not able to answer. I took a look since last time. So my change looks definetely wrong. |
@lcharlois-neotys, I had now time to look into this problem. According to this link [1] JSON Schema is using ISO_8601 [2] and in particular ISO 8601 Collected ABNF [3], which states
Which explains [1] https://json-schema.org/understanding-json-schema/reference/string#dates-and-times |
@pk-work Thanks for your detailed answer. I don't share your analysis and still think that Looking more attentively to the project I've seen that the library is able to correctly validate the The implmentation relies on the class I can still take the time to fix, but here I will need more guidance on how to enable PS: Regarding the |
@lcharlois-neotys You are right, I just concentrated on the "T", but the value "1D" (1 day), must be added directly after the "P" not the "T". I now looked into the other test cases, and found that "P1YT" is also invalid. But as I mentioned above I thought the "T" is required. So I'm a little bit confused ... But for now I would say the test suite is the truth. |
@pk-work From what I understand: |
I think OpenAPI 3.0 is using Draft4 [1]. Which would explain why "duration" is not available. |
@pk-work You're right. |
Hey, this was a great discussion. I just made ajv-validator/ajv-formats#87 for ajv, and we need support for negative duration for our Java users in this library. If we make a PR that allows that, will that be accepted? Thanks, Kenneth |
Is a "negative duration" something somewhere mentioned in the official spec? Haven't found it so far. |
It's not easy to find as the ISO is behind a paywall... But I managed to find https://www.postgresql.org/message-id/9q0ftb37dv7.fsf%40gmx.us which explains that this is covered by the 2019 edition of ISO-8601. It's supported by Another good discussion here: tc39/proposal-temporal#782 |
Fix #116
Motivation:
"duration" format is valid since RFC 2019-09 and in OpenApi 3.0.