Skip to content

Allow namespaced extension properties on 3.0 Manifest and AnnotationPage - #228

Open
Zwiterrion wants to merge 1 commit into
IIIF:mainfrom
Zwiterrion:v3-extension-properties
Open

Zwiterrion wants to merge 1 commit into
IIIF:mainfrom
Zwiterrion:v3-extension-properties

Conversation

@Zwiterrion

Copy link
Copy Markdown

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 metadata into 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:

Additional properties are not allowed ('ext:project' was unexpected)

I traced it to additionalProperties: false on the manifest and annotationPage definitions of schema/iiif_3_0.json. As far as I can tell, the specification allows these properties:

  • §3 Resource Properties: "Other properties are allowed, either via local extensions or those endorsed by the IIIF community. If a client discovers properties that it does not understand, then it must ignore them."
  • §4.6 Linked Data Context and Extensions: additional properties "should be mapped to RDF predicates using further context documents", and these contexts "must be added before" the IIIF context.

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.json shows a GeoJSON extension accepted at the Annotation level), and that the 4.0 schema in this repository does not restrict them on Manifest or AnnotationPage.

Change

I added a patternProperties entry next to additionalProperties: false on manifest and annotationPage:

"patternProperties": {
    "^[A-Za-z][A-Za-z0-9_.-]*:[^/].*$": {}
}

Keys written as compact IRIs (prefix:suffix) are accepted with any value. I kept additionalProperties: false on 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:project at the Manifest root and ext:note on the Canvas's AnnotationPage.
  • fixtures/3/broken_typo_property.json, in the bad list, as a guard: an otherwise valid Manifest with a misspelled sumary key.

Then I ran both through a local instance of the validator (iiif-validator serve, then POST /validate), one schema change at a time:

Schema extension_manifest.json broken_typo_property.json
main fails: ext:project on /, ext:note on /items[0]/items[0] fails
manifest change only fails: ext:note on /items[0]/items[0] fails
both changes passes fails

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 patternProperties is present:

  • before: Additional properties are not allowed ('sumary' was unexpected)
  • after: '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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant