Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Validate valueset schema(s) #70

Merged
merged 10 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Tests

on:
- push
- pull_request

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install general dependencies
run: sudo apt-get install jq nodejs
- name: Install node dependencies
run: npm install
- name: Validate the valuesets
run: npm test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
25 changes: 0 additions & 25 deletions DCC.ValueSets.schema.json

This file was deleted.

43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,49 @@ The JSON Schema definition for the structure used for all of the above valuesets

Finally the we have [changelog](CHANGELOG.md), [license](LICENSE.md) and [versioning](VERSIONING.md) files and, of course, this [readme](README.md).


## Working with the valuesets

### NOTE FOR WINDOWS USERS

The scripts we used are bash-based, if you're a Windows users you will either need to use the amazing [Windows Subsystem for Linux](https://learn.microsoft.com/en-us/windows/wsl/install) or use another [Cygwin](https://www.cygwin.com/).

Although the maintainers are primarily Windows developers the internet - and the git eco-system - are POSIX focused. With the fantastic support for POSIX on modern Windows we have decided to focus on a POSIX-based workflow.

### Pre-reqs

[Node.js 18.14.2 or above ](https://nodejs.org/en/)
NPM 9.5.0 (included with Node.js)

### Configuring git hooks

This repository makes use of the `pre-commit` git hook. This executes the schema validation scripts (which are described below).

To enable git hooks you need to tell git to use them, you can do that by running this command from the terminal in the root directory of this project:

git config core.hooksPath hooks

### Validating schema

First lets ask node to install the dependencies:

npm install

Then to run the schema validator simply:

npm test

If there are any validation errors they will be shown on the screen.

## How the schema and validator work

We use [JSON Schema 2020-12](https://json-schema.org/specification.html) to define the schema of the valuesets. For most of the valuesets there is a [shared schema](schemas/DCC.ValueSets.schema.json).

For files which have a different schema - such as `vaccine-encoding-instructions` - the validator supports the definition of a custom schema. By convention these schema files are named `<valueset-file-name>.schema.json` and are stored in `./schema`. So for `vaccine-encoding-instructions.json` the schema `vaccine-encoding-instructions.schema.json` is used.

The validator code has been written in an imperative style for ease of understanding and [can be found in the schema directory](schemas/validate-valuesets.js).


## Governance

The valuesets are owned by the eHealth Network Subgroup on Semantics (SSG). Any requests for additions or changes must be directed to that group. If you or your country are not members of that subgroup then you can raise an issue on this GitHub repository and, if appropriate, we will raise it with the SSG on your behalf.
Expand Down
8 changes: 8 additions & 0 deletions hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh
#

# Ensure npm pre-reqs are installed
npm install

# Run the NPM tests
npm test || exit 1
273 changes: 273 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"dependencies": {
"ajv": "^8.12.0",
"ajv-cli": "^5.0.0",
"ajv-formats": "^2.1.1"
},
"scripts": {
"test": "node schemas/validate-valuesets.js"
}
}
Loading