Repository navigation
Allow namespaced extension properties on 3.0 Manifest and AnnotationPage - #228
Open
Zwiterrion wants to merge 1 commit into
Open
Zwiterrion wants to merge 1 commit into
Zwiterrion wants to merge 1 commit 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.