readium / r2-streamer-js

NodeJS Readium2 "streamer"
BSD 3-Clause "New" or "Revised" License
21 stars 10 forks source link

JSON Schema validation #29

Closed danielweck closed 6 years ago

danielweck commented 6 years ago

See: https://github.com/readium/webpub-manifest/tree/master/schema

Note that the JSON schemas as divided: "$ref": "https://URL_TO_OTHER.schema.json"

danielweck commented 6 years ago

https://ajv.js.org https://github.com/epoberezkin/ajv

"$ref" handling: https://github.com/epoberezkin/ajv#combining-schemas-with-ref

danielweck commented 6 years ago

https://github.com/tdegrunt/jsonschema/issues/255

"$ref" handling: https://github.com/tdegrunt/jsonschema#dereferencing-schemas

danielweck commented 6 years ago

Implemented in https://github.com/edrlab/r2-streamer-js/commit/76bf4484a93bc96bf7e0628454d455455b8c7db2 using ajv (see comment above), with the JSON schema adapted at https://github.com/danielweck/webpub-manifest/tree/master/schema (see PR https://github.com/readium/webpub-manifest/pull/9 ).

Validation is performed for demonstration purposes at the /manifest.json/show/all URL, for instance: https://readium2.herokuapp.com/pub/L2FwcC9taXNjL2VwdWJzL2NoaWxkcmVucy1saXRlcmF0dXJlLmVwdWI%3D/manifest.json/show/all (scroll all the way down to the bottom of the page, where the validation report is generated)