From 53b930ec8c91959b13b6757c0b3ce6b71537981d Mon Sep 17 00:00:00 2001 From: Hadrien Gardeur Date: Tue, 31 Jul 2018 12:00:15 +0200 Subject: [PATCH] Added more validations in JSON Schema related #8 Validates the presence of the templated flag for URI templates Validates the presence of a media type in readingOrder and resources --- schema/contributor-object.schema.json | 1 + schema/link.schema.json | 34 +++++++++++++++++++-------- schema/publication.schema.json | 22 ++++++++++++++++- 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/schema/contributor-object.schema.json b/schema/contributor-object.schema.json index bc72bc0..d8b9388 100644 --- a/schema/contributor-object.schema.json +++ b/schema/contributor-object.schema.json @@ -2,6 +2,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "id": "http://readium.org/webpub-manifest/schema/contributor-object.schema.json", "title": "Contributor Object", + "type": "object", "properties": { "name": { "type": ["string", "object"] diff --git a/schema/link.schema.json b/schema/link.schema.json index 159b8a9..9ecccf5 100644 --- a/schema/link.schema.json +++ b/schema/link.schema.json @@ -2,18 +2,11 @@ "$schema": "http://json-schema.org/draft-07/schema#", "id": "http://readium.org/webpub-manifest/schema/link.schema.json", "title": "Link Object for the Readium Web Publication Manifest", + "type": "object", "properties": { "href": { "description": "URI or URI template of the linked resource", - "type": "string", - "anyOf": [ - { - "format": "uri" - }, - { - "format": "uri-template" - } - ] + "type": "string" }, "type": { "description": "MIME type of the linked resource", @@ -54,5 +47,26 @@ "type": "boolean" } }, - "required": ["href"] + "required": ["href"], + "oneOf": [ + { + "properties": { + "templated": { + "const": true + }, + "href": { + "format": "uri-template" + } + }, + "required": ["templated"] + }, + { + "properties": { + "href": { + "format": "uri" + } + } + } + + ] } \ No newline at end of file diff --git a/schema/publication.schema.json b/schema/publication.schema.json index 3040aee..4634a15 100644 --- a/schema/publication.schema.json +++ b/schema/publication.schema.json @@ -26,5 +26,25 @@ } } }, - "required": ["metadata", "links", "readingOrder"] + "required": ["metadata", "links", "readingOrder"], + "allOf": [ + { + "properties": { + "readingOrder": { + "items": { + "required": ["type"] + } + } + } + }, + { + "properties": { + "resources": { + "items": { + "required": ["type"] + } + } + } + } + ] } \ No newline at end of file