IIIF/presentation-validator

Handling reference to Manifest, AnnotationPage, Collection, AnnotationCollection, Canvas

giacomomarchioro opened this issue · 1 comments

Collections can contain references to manifests as described here which have a limited subset of required attributes and do not contain items. Hence, requiring the Collection to contain only fully-featured manifests is not correct see: iiif-prezi/iiif-prezi3#8

There are different approaches to solve this issue, I have tried to create a class reference as shown below:

"reference": {
            "allOf": [
                { "$ref": "#/types/class" },
                {
                    "type": "object",
                    "additionalProperties": true,
                    "properties": {
                        "id": { "$ref": "#/types/id" },
                        "label": {"$ref": "#/types/lngString" },
                        "type": {
                            "type": "string",
                            "pattern": "^Manifest$|^AnnotationPage$|^Collection$|^AnnotationCollection$|^Canvas$"
                        },
                        "thumbnail": {
                            "type": "array",
                            "items": { "$ref": "#/classes/resource" }
                        }
                    },
                    "required": ["id", "type", "label"],
                    "not": { "required": [ "items" ] }
                }
            ]
        },

However setting "additionalProperties": true which is required to let the addition of other properties that differ in each of the referenceable IIIF objects allow the user to add also any other properties hence potentially breaking the manifest. At the moment the only solution that seems to be safe is to clone each of the following object definitions in the JSON schema (Manifest, AnnotationPage, Collection, AnnotationCollection, Canvas) removing the items field and renaming to something different e.g. refManifest, refAnnotatioPage etc. etc.

I also tried to see if I can overload a property ineheriting all the other using this code:

 "reference": {
            "allOf": [
                { "$ref": "#/types/class" },
                {   
                    "anyOf" : [
                        {"allOf": [{ "$ref": "#/classes/annotationPage" }]},
                        {"allOf": [{ "$ref": "#/classes/manifest" }]},
                        {"allOf": [{ "$ref": "#/classes/collection" }]},
                        {"allOf": [{ "$ref": "#/classes/canvas" }]},
                        {"allOf": [{ "$ref": "#/classes/annotationCollection" }]}
                    ],
                    "required": ["id", "type", "label"],
                    "not": { "required": [ "items" ] }
                }
            ]
        },

But it doesn't seem to work. Any suggestions?

I believe this has now been fixed.