Description
The vocabulary tests here are not strictly correct according to the spec, unless I'm missing something. They appear to assert that if the validation vocabulary isn't present, that an implementation must mark instances as valid even if the validation vocabulary says they are not -- but that's not the specified (or intended) behavior of $vocabulary
as far as I know. Quoting §6.5:
Additional schema keywords and schema vocabularies MAY be defined by any entity. Save for explicit agreement, schema authors SHALL NOT expect these additional keywords and vocabularies to be supported by implementations that do not explicitly document such support.
I.e. a schema author may not depend on support for a keyword or vocabulary they use but do not place in $vocabulary
, but an implementation may indeed offer support for it and enable it, either by always enabling the vocabulary or because it has chosen to add a keyword called "minimum" whose behavior is precisely the same as the validation vocabulary's, and then enable it by default regardless of what's in $vocabulary
.
When the $vocabulary
keyword does have mandatory effect is in the converse -- where an implementation lacks support for a vocabulary and a schema author requires its use, the implementation may not ignore those keywords:
The values of the object properties MUST be booleans. If the value is true, then implementations that do not recognize the vocabulary MUST refuse to process any schemas that declare this meta-schema with "$schema". If the value is false, implementations that do not recognize the vocabulary SHOULD proceed with processing such schemas. The value has no impact if the implementation understands the vocabulary.
from §8.1.2.
TL;DR, an implementation given this schema:
{
"$id": "https://schema/using/no/validation",
"$schema": "http://localhost:1234/draft2020-12/metaschema-no-validation.json",
"properties": {
"badProperty": false,
"numberProperty": {
"minimum": 10
}
}
}
(with metaschema here) is indeed free to still apply the validation vocabulary, or to similarly define some behavior for the minimum
keyword which makes instances like 20
be invalid.
In "today's test layout", the above means that these tests belong in optional
, though given we have #561 on hold pending restructuring the optional/
directory, perhaps we instead should remove them and do the same with these?
CC @handrews (since I believe you confirmed the above interpretation previously, but just making sure) and @karenetheridge (since you added these looks like, in case you disagree).