Skip to content

Commit

Permalink
Added validation for self link
Browse files Browse the repository at this point in the history
related #8
  • Loading branch information
Hadrien Gardeur committed Jul 31, 2018
1 parent 53b930e commit 7de8aed
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
]
}
```
Expand Down
1 change: 1 addition & 0 deletions schema/link.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"required": ["href"],
"oneOf": [
{
"description": "A URI template should also include the proper flag.",
"properties": {
"templated": {
"const": true
Expand Down
27 changes: 27 additions & 0 deletions schema/publication.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -38,13 +39,39 @@
}
},
{
"description": "All resources listed in the publication should contain a media type.",
"properties": {
"resources": {
"items": {
"required": ["type"]
}
}
}
},
{
"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"
}
}
]
}
}
}
}
}
}
]
}

0 comments on commit 7de8aed

Please sign in to comment.