Closed vdweij closed 9 months ago
As the link you yourself shared says, items
with an array is called prefixItems
in newer JSON Schema versions, and your schema is indeed therefore invalid in those versions.
Using another lib (https://github.com/ajv-validator/ajv) via https://extendsclass.com/json-schema-validator.html shows it is valid. Also https://www.jsonschemavalidator.net/ (https://github.com/JamesNK/Newtonsoft.Json) shows it is valid.
Both of these libraries are notoriously buggy by the way.
Thnx... I did find a related issue https://github.com/python-jsonschema/jsonschema/issues/1015 I guess I need to specify the $schema version in this case.
If you intend your schema to be for an older version, yes.
In a json schema you could define a 'tuple' array (https://json-schema.org/understanding-json-schema/reference/array#tupleValidation) like:
meaning the corresponding json could look like this:
The order of the types is important and no additional values are allowed because
additionalItems
is set to false.Above json should conform to the specified schema. However I get a SchemaError when I try to validate this using the lib
jsonschema
. It looks like the schema itself is considered invalid.Using another lib (https://github.com/ajv-validator/ajv) via https://extendsclass.com/json-schema-validator.html shows it is valid. Also https://www.jsonschemavalidator.net/ (https://github.com/JamesNK/Newtonsoft.Json) shows it is valid.
Below a simple reproduction snippet
Results in: