Skip to content

Commit

Permalink
Added more validations in JSON Schema
Browse files Browse the repository at this point in the history
related #8
Validates the presence of the templated flag for URI templates
Validates the presence of a media type in readingOrder and resources
  • Loading branch information
Hadrien Gardeur committed Jul 31, 2018
1 parent 27c02f5 commit 53b930e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 11 deletions.
1 change: 1 addition & 0 deletions schema/contributor-object.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
34 changes: 24 additions & 10 deletions schema/link.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
}

]
}
22 changes: 21 additions & 1 deletion schema/publication.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,25 @@
}
}
},
"required": ["metadata", "links", "readingOrder"]
"required": ["metadata", "links", "readingOrder"],
"allOf": [
{
"properties": {
"readingOrder": {
"items": {
"required": ["type"]
}
}
}
},
{
"properties": {
"resources": {
"items": {
"required": ["type"]
}
}
}
}
]
}

0 comments on commit 53b930e

Please sign in to comment.