This repo defines a set of json-schema (draft v7) files we can use across multiple codebases to validate our prototype-viewer's event schema.
When you receive an event, you should first validate the entire event against the schema in event.json
. That schema will ensure the basic event structure is correct, and that it has all required top level keys with correct type
values if appropriate.
If that's valid, you need to take object in the trigger
key and validate it against the schema in triggers/:type.json
, where :type
is the value of the trigger's type
key. Then you should do the same for the object
and outcome
keys.
For example, if you have an event that looks like the following:
{
"trigger": {
"type": "timer",
},
"object": {
"type": "screen",
"id": 1,
"height": 100,
"width": 100
},
"outcome": {
"type": "screenTransition",
"fromScreen": 1,
"toScreen": 2,
"animation": "fade"
},
"timestamp": 2500,
"id": "6503601444799647744",
"prevId": "6503601444803842048"
}
After validating the entire event using event.json
, you'd need to take the trigger
object and validate against triggers/timer.json
, use objects/screen.json
to validate the object
value and validate the outcome
with outcomes/screenTransition.json
ProTip: jsonschema.net is a useful tool for creating and updating the schema files
- Update
event.json
to accept your newtype
value for thetrigger
,object
oroutcome
keys as appropriate - Add a schema file to the
triggers/
,objects/
oroutcomes/
directory, with the same name as yourtype
value. So atimer
type becomestimer.json
- Add or update at least a basic test in
validate.js
- Alter package.json version and increment depending on whether it is a patch, minor or major change
- run
npm publish
to update the published npm package - update
setup.py
and alter theversion
- To publish the python package, run a git tag.
git tag v3.x.x
to the specific version you want to tag. Alter the referenced python package in requirements.txt as required. (e.g. git+https://github.com/marvelapp/[email protected]#egg=marvel-proto-events)