Status: Proposed
Date: November 2, 2024
Deciders: @gregsdennis @jdesrosiers @julian @jviotti @mwadams @karenetheridge @relequestual
Date: November 2, 2024
Deciders: @gregsdennis @jdesrosiers @julian @jviotti @mwadams @karenetheridge @relequestual
Context and Problem Statement
Theformat keyword has a long and complex history in JSON Schema that has led to inconsistent behavior across implementations and ongoing confusion for users.
Historical Background
- From Draft 01:
formathas never required validation - Implementation choice: Whether to support format validation has always been up to implementations
- Extent of validation: How thoroughly formats are validated has also been implementation-dependent
This inconsistency has resulted in spotty implementation support. Even implementations that do support validation don’t all support each format equally, despite the JSON Schema specs referencing very concretely defined formats from other specifications.
Evolution of Format Behavior
2019-09: Introduced schema-author control- Schema authors could enable validation by using a meta-schema listing the Format Vocabulary with
true - This meant “format validation is required to process this schema”
- Offered two vocabularies: one treating
formatas annotation, one as assertion - Argument: keyword behavior shouldn’t change based on whether vocabulary is required
format to validate by default.
Decision Drivers
Four main factors influenced this decision:- User expectation: Consistent reports that users expect
formatto validate - Current behavior: Existing annotation-only behavior is confusing
- Historical context: Long history of optional validation
- Implementation disparity: Gap between current support and proposed requirements
Voting Results
TSC Vote Breakdown
TSC Vote Breakdown
For: @gregsdennis @jdesrosiers @jviotti @mwadams @karenetheridge
Neutral: @relequestual
Against: @julianView voting issue
Neutral: @relequestual
Against: @julianView voting issue
Options Considered
Option 1: Format Remains Annotation (Current State)
format continues as an annotation keyword by default.
Benefits:
- No breaking change required
- Maintains backward compatibility
- Current system is confusing (requires tool configuration or
format-assertionvocab) - Doesn’t align with user expectations
- The
format-assertionvocabulary will no longer be an option since vocabularies were demoted to a proposal for the stable release
Option 2: Format Becomes Assertion (CHOSEN)
The spec now requires
format validation by default.- SHOULD support: Implementations should support
formatwith the defined values - MAY support custom: Implementations may support other formats, but only by explicit configuration
- MUST refuse: Implementations must refuse to process a schema containing an unsupported format
Decision Outcome
The TSC voted to changeformat to act as an assertion by default, adopting Option 2.
Positive Consequences
Aligns with expectations: Matches what users consistently expectformat to do
Annotation alternative: Users who want purely annotative behavior can use custom keywords like x-format (see the Single-Value Annotations ADR)
Increased consistency: Format validation will be more consistent across implementations
Negative Consequences
Breaking Change Implications
Breaking Change Implications
User re-education: Users who correctly treat
format as an annotation will need to be informed of the changeSchema version ambiguity: Older schemas without a $schema keyword may change their validation outcomeImplementation burden: Greater burden on implementations since format validation was previously optionalImplementation Requirements
With this change, implementations must:- Validate by default: Treat
formatas an assertion that can fail validation - Support defined formats: Implement the formats specified in the JSON Schema specification
- Reject unknown formats: Refuse to process schemas with unsupported format values (unless explicitly configured otherwise)
- Test suite compliance: Pass the required format validation tests that are now in the mandatory section
The test suite is being expanded to strictly enforce format validation with more complete test coverage for all defined formats.
Migration Guide
For users of existing schemas: If you want annotation-only behavior:Schemas should always include a
$schema keyword to explicitly declare which version of JSON Schema they target, avoiding ambiguity in format behavior.