test(duration): expand RFC 3339 grammar coverage for duration format#868
Conversation
|
For reference: https://www.rfc-editor.org/rfc/rfc3339#appendix-A |
I think its important to add test cases proving you reject the ones with fractional durations if the Appendix doesn't allow them |
|
Other than that the new ones you added seem correct |
…rmat Signed-off-by: Vaibhav mittal <vaibhavmittal929@gmail.com>
Signed-off-by: Vaibhav mittal <vaibhavmittal929@gmail.com>
989f7e7 to
5489c49
Compare
|
Thanks for the clarification and the reference @jviotti . I’ve added a test case rejecting fractional duration components (PT0.5S) based on the RFC 3339 Appendix A ABNF grammar. |
This PR adds a few additional tests for the
durationformat based on the ABNF grammar in RFC 3339 Appendix A, which is referenced by the JSON Schema specification.The goal is to improve coverage of grammar paths that were not clearly exercised by the existing tests. The new cases cover:
Y → M → D)H → M → S)PT...)H → Mwithout seconds1*DIGITAll tests are derived directly from the RFC grammar structure rather than adding new interpretation rules.
One case that is intentionally not included is fractional durations (for example
PT0.5S). The JSON Schema spec defines the format as “the ISO 8601 ABNF as given in Appendix A of RFC 3339”. The ABNF grammar in that appendix only allows digits (1*DIGIT), while ISO-8601 itself allows fractional values. Because of this, different implementations currently behave differently:ajv-formats) rejects fractional valuespython-jsonschemaaccepts them through theisodurationlibrarySince the specification wording leaves this ambiguous, this PR avoids adding tests that would enforce either interpretation.
The same changes are applied consistently to the
draft2020-12,draft2019-09, andv1test files, with only the$schemavalue differing between them.Before submitting the PR I validated the files using the repository tools (
python3 bin/jsonschema_suite check) and verified JSON syntax withpython3 -m json.tool. All checks passed.