2020-12 Schema: Tuples and Backwards Compatibility #335
-
Hi -- In the JSON Schema 2020-12 release notes, there is a section going over the changes made to the
Given the change, should a JSON Schema library that handles the 2020-12 schema be implemented in a way that it remains backwards compatible with how a tuple is defined using the 2019-09 schema? For example, would the following schemas still be valid for when validated against JSON Schema 2020-12: // Open tuple
{
"items": [
{ "$ref": "#/$defs/foo" },
{ "$ref": "#/$defs/bar" }
]
}
// Closed tuple
{
"items": [
{ "$ref": "#/$defs/foo" },
{ "$ref": "#/$defs/bar" }
],
"additionalItems": false
}
// Tuple with constrained additional items
{
"items": [
{ "$ref": "#/$defs/foo" },
{ "$ref": "#/$defs/bar" }
],
"additionalItems": { "$ref": "#/$defs/baz" }
} My assumption is that, no, defining a tuple using the JSON Schema 2020-12 spec is not backwards compatible with how tuples are defined in the JSON Schema 2019-09 spec. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
You're correct, because However, the split of the array form of The following are now what you'll need to record the same requirements. // Open tuple
{
"prefixItems": [
{ "$ref": "#/$defs/foo" },
{ "$ref": "#/$defs/bar" }
]
}
// Closed tuple
{
"prefixItems": [
{ "$ref": "#/$defs/foo" },
{ "$ref": "#/$defs/bar" }
],
"items": false
}
// Tuple with constrained additional items
{
"prefixItems": [
{ "$ref": "#/$defs/foo" },
{ "$ref": "#/$defs/bar" }
],
"items": { "$ref": "#/$defs/baz" }
} |
Beta Was this translation helpful? Give feedback.
-
@Relequestual Yeah, makes sense. The
Thanks for the help! |
Beta Was this translation helpful? Give feedback.
You're correct, because
additionalItems
isn't a keyword anymore, this isn't a compatible change from 2019-09 to 2020-12. None of those schemas you posted are valid for 2020-12.However, the split of the array form of
items
toprefixItems
provides the same functionality.The following are now what you'll need to record the same requirements.