Repository navigation
Report unknown properties on 3.0 Manifest and AnnotationPage as warnings - #228
Zwiterrion wants to merge 2 commits into
Conversation
The 3.0 schema sets additionalProperties to false on manifest and annotationPage, so extension properties on these resources fail validation, although Presentation 3.0 allows them (sections 3 and 4.6). Accept keys written as compact IRIs (prefix:suffix) through patternProperties, and keep rejecting unprefixed unknown keys so that misspelled properties are still reported.
|
Hi, thanks so much for this, and for such a thorough write-up. I like how neat the solution is, but I’m hesitant to merge it as it stands. The specification doesn’t require extension properties to be namespaced or written as compact IRIs. §3 and §4.6 only say that other properties are allowed and should be mapped to RDF through additional context documents placed before the IIIF context. With this pattern, the validator would accept prefix:suffix keys but still reject unprefixed ones. In effect it would be enforcing a naming convention that isn’t in the spec, so a spec-compliant Manifest could still fail depending on how its extension keys are named. I’d rather not make the validator stricter than the specification in that particular way. The alternative, allowing additionalProperties on Manifest and AnnotationPage, has the opposite problem. It would quietly accept typos like sumary, and I think catching those is one of the most useful things the validator does. As you pointed out, that’s already happening at other levels, which isn’t ideal either. (note the misspelling in the current validator should be a separate issue) Ideally, unknown properties would be reported as warnings rather than errors, but JSON Schema doesn’t support that. We’d need two copies of the schema, a strict one and a lenient one, and keeping them in sync would be hard to maintain. So for now I’d prefer to keep the current behaviour, where unrecognised properties on Manifest and AnnotationPage are reported as errors, and make it clearer in the documentation that some of these errors may be valid extensions you can safely ignore. Thanks again for taking the time on this. |
Instead of accepting only prefixed keys in the schema, keep the schema as it is on main and sort its additionalProperties errors in the v3 validator: - on a Manifest or AnnotationPage, a key the schema does not define anywhere is reported as a warning (an extension, or a typo such as "sumary"); - a property the schema does define, used where it is not allowed (e.g. "annotations" on an AnnotationPage), is still an error; - additionalProperties errors on other objects are unchanged. A result with warnings and no errors now passes. validate-dir prints warnings for passing files too, so they show up in CI logs.
|
Thanks for the review, that makes sense. You're right that the spec doesn't ask for prefixes, I misread it. About the warnings, I think that is a good process to explore but I don't think it needs two schemas.
A result with warnings and no errors passes. validate-dir now prints warnings for passing files too, so they still show up in the Action's logs. For fixtures:
If you'd still rather keep the current behaviour and only document it, I'm happy to close this and open a docs PR instead. |
Hi! I'm working on Adno, an open-source web application for viewing, editing and sharing narratives and guided explorations on IIIF and static images. We are currently making Adno's exports conform to IIIF Presentation 3.0 and the W3C Web Annotation Data Model.
Context
I planned to check Adno's exports in our CI with this validator's GitHub Action. In our new export, an Adno project becomes a IIIF 3 Manifest. The editor's own data (viewer settings, image list) moves out of
metadatainto a namespaced key at the Manifest root,adno:project, declared by our own context placed before the IIIF context.I cloned the repository locally and tested a minimal Manifest with that shape. The validator rejects it:
I traced it to
additionalProperties: falseon themanifestandannotationPagedefinitions ofschema/iiif_3_0.json. As far as I can tell, the specification allows these properties:I also noticed that the rest of the 3.0 schema already accepts extra properties on Canvas, Annotation, Collection and AnnotationCollection (
fixtures/3/extension_anno.jsonshows a GeoJSON extension accepted at the Annotation level), and that the 4.0 schema in this repository does not restrict them onManifestorAnnotationPage.Change
I added a
patternPropertiesentry next toadditionalProperties: falseonmanifestandannotationPage:Keys written as compact IRIs (
prefix:suffix) are accepted with any value. I keptadditionalProperties: falseon purpose: unprefixed unknown keys are still rejected, so a misspelled IIIF property is still reported. Absolute IRIs (https://…) do not match, because the suffix may not start with/.How I tested it
I wrote two fixtures first:
fixtures/3/extension_manifest.json, in the good list: an extension context before the IIIF context,ext:projectat the Manifest root andext:noteon the Canvas's AnnotationPage.fixtures/3/broken_typo_property.json, in the bad list, as a guard: an otherwise valid Manifest with a misspelledsumarykey.Then I ran both through a local instance of the validator (
iiif-validator serve, thenPOST /validate), one schema change at a time:extension_manifest.jsonbroken_typo_property.jsonmainext:projecton/,ext:noteon/items[0]/items[0]manifestchange onlyext:noteon/items[0]/items[0]I also ran
pytest tests/test_validator.py, and it passes. No existing fixture uses a prefixed key, so no other test result changes.Side effect
While testing, I noticed that jsonschema words the error for an unknown key differently once
patternPropertiesis present:Additional properties are not allowed ('sumary' was unexpected)'sumary' does not match any of the regexes: '^[A-Za-z][A-Za-z0-9_.-]*:[^/].*$'The error path is unchanged.
Happy to adjust the pattern, the fixtures or the wording if you prefer another approach.