From 7de8aedbf0f25544cadd22b98efb38af6ebff194 Mon Sep 17 00:00:00 2001 From: Hadrien Gardeur Date: Tue, 31 Jul 2018 12:37:57 +0200 Subject: [PATCH] Added validation for self link related #8 --- README.md | 20 ++++++++++---------- schema/link.schema.json | 1 + schema/publication.schema.json | 27 +++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 9569eb4..5e3cea4 100644 --- a/README.md +++ b/README.md @@ -16,22 +16,22 @@ }, "links": [ - {"rel": "self", "href": "http://example.org/manifest.json", "type": "application/webpub+json"}, - {"rel": "alternate", "href": "http://example.org/publication.epub", "type": "application/epub+zip"}, - {"rel": "search", "href": "http://example.org/search{?query}", "type": "text/html", "templated": true} + {"rel": "self", "href": "https://example.com/manifest.json", "type": "application/webpub+json"}, + {"rel": "alternate", "href": "https://example.com/publication.epub", "type": "application/epub+zip"}, + {"rel": "search", "href": "https://example.com/search{?query}", "type": "text/html", "templated": true} ], "readingOrder": [ - {"href": "c001.html", "type": "text/html", "title": "Chapter 1"}, - {"href": "c002.html", "type": "text/html", "title": "Chapter 2"} + {"href": "https://example.com/c001.html", "type": "text/html", "title": "Chapter 1"}, + {"href": "https://example.com/c002.html", "type": "text/html", "title": "Chapter 2"} ], "resources": [ - {"rel": "cover", "href": "cover.jpg", "type": "image/jpeg", "height": 600, "width": 400}, - {"href": "style.css", "type": "text/css"}, - {"href": "whale.jpg", "type": "image/jpeg"}, - {"href": "boat.svg", "type": "image/svg+xml"}, - {"href": "notes.html", "type": "text/html"} + {"rel": "cover", "href": "https://example.com/cover.jpg", "type": "image/jpeg", "height": 600, "width": 400}, + {"href": "https://example.com/style.css", "type": "text/css"}, + {"href": "https://example.com/whale.jpg", "type": "image/jpeg"}, + {"href": "https://example.com/boat.svg", "type": "image/svg+xml"}, + {"href": "https://example.com/notes.html", "type": "text/html"} ] } ``` diff --git a/schema/link.schema.json b/schema/link.schema.json index 9ecccf5..f793bb8 100644 --- a/schema/link.schema.json +++ b/schema/link.schema.json @@ -50,6 +50,7 @@ "required": ["href"], "oneOf": [ { + "description": "A URI template should also include the proper flag.", "properties": { "templated": { "const": true diff --git a/schema/publication.schema.json b/schema/publication.schema.json index 4634a15..4ca7b27 100644 --- a/schema/publication.schema.json +++ b/schema/publication.schema.json @@ -29,6 +29,7 @@ "required": ["metadata", "links", "readingOrder"], "allOf": [ { + "description": "All resources listed in the reading order should contain a media type.", "properties": { "readingOrder": { "items": { @@ -38,6 +39,7 @@ } }, { + "description": "All resources listed in the publication should contain a media type.", "properties": { "resources": { "items": { @@ -45,6 +47,31 @@ } } } + }, + { + "description": "A publication must contain at least one self link.", + "properties": { + "links": { + "contains": { + "properties": { + "rel": { + "anyOf": [ + { + "type": "string", + "const": "self" + }, + { + "type": "array", + "contains": { + "const": "self" + } + } + ] + } + } + } + } + } } ] } \ No newline at end of file