Public JSON schemas for SPINE
If you make changes and tag this project make sure that the version of the package.json
file is the same as the tagged version of the repository. This will allow the front-end of SPINE to npm install
the correct version.
- We have a version of the schema used in the SPINE project saved in a document in the database. All the documents in the database have to be compliant with this schema.
- The front-end will generate the schema validator in a static way given that all the documents are in the same json schema version.
- We need to provide migration scripts for the database for each change in the schema.
- Update schema documents
- Update the version of the
package.json
file - Commit, Pull Request, and Merge into the master branch
- Tag this repository according to the version in the
package.json
file - In the SPINE repository change the version of this repository in the dependences in the
package.json
file - In SPINE project run
npm install
- Create migration script for the database and save it the SPINE repository in the folder
src/backedn/migrations_scripts/
. The migration script changes at least the document having the version of the json schema used. - Create a release for SPINE project including migration instructions from previous releases. Please refer to the migration script in the commit messages.
All schemas should be validated with tests, based on Ajv library. Since Jest can’t specify the error message, in order to display a meaningful error message, we will have to create a custom matcher to show our own message, returned by Ajv. It is shown in Example of matcher extension.
Examples used for testing are defined in "examples" subfolders. To identify weak tests Mutation tests are applied (json files with mutation. prefix). Manual tools definitions can be tested using automatic suite
Test JSON schema with AJV and Jest
TODO: Set up coverage as in Ajv-Istanbul