diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 037abe6..889f8be 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,6 +33,10 @@ jobs: ${PKGCONF:-} \ cmake \ make \ + python3 \ + python3-pip + + sudo pip install jsonschema - name: ๐Ÿ› ๏ธ Build run: | @@ -49,4 +53,13 @@ jobs: - name: ๐Ÿงช Perform Unit Tests run: | cd tests/build - ctest \ No newline at end of file + ctest + - name: ๐Ÿ“Ž Validate JSON Files + run: | + cd constants + for file in ./[!_schema.json]*; do jsonschema -i $file _schema.json; done + cd .. + + cd tips + for file in ./[!_schema.json]*; do jsonschema -i $file _schema.json; done + cd .. diff --git a/constants/_schema.json b/constants/_schema.json new file mode 100644 index 0000000..9cd1cc5 --- /dev/null +++ b/constants/_schema.json @@ -0,0 +1,73 @@ +{ + "definitions": {}, + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://example.com/object1655988398.json", + "title": "Root", + "type": "object", + "required": [ + "name", + "values" + ], + "properties": { + "name": { + "$id": "#root/name", + "title": "Name", + "type": "string", + "default": "", + "examples": [ + "Group description" + ], + "pattern": "^.*$" + }, + "values": { + "$id": "#root/values", + "title": "Values", + "type": "array", + "default": [], + "items":{ + "$id": "#root/values/items", + "title": "Items", + "type": "object", + "required": [ + "type", + "value", + "name" + ], + "properties": { + "type": { + "$id": "#root/values/items/type", + "title": "Type", + "type": "string", + "default": "", + "examples": [ + "int16be", + "int16le", + "int10" + ], + "pattern": "^(int10|int16le|int16be)$" + }, + "value": { + "$id": "#root/values/items/value", + "title": "Value", + "type": "string", + "default": "", + "examples": [ + "ACDC" + ], + "pattern": "^([0-9a-fA-F]+)$" + }, + "name": { + "$id": "#root/values/items/name", + "title": "Name", + "type": "string", + "default": "", + "examples": [ + "Constant description" + ], + "pattern": "^.*$" + } + } + } + } + } +} diff --git a/constants/http_status.json b/constants/http_status.json index 3915f99..e5d4a8c 100644 --- a/constants/http_status.json +++ b/constants/http_status.json @@ -128,7 +128,7 @@ }, { "type": "int10", - "value": "402 ", + "value": "402", "name": "Payment Required" }, { diff --git a/tips/_schema.json b/tips/_schema.json new file mode 100644 index 0000000..d5a6650 --- /dev/null +++ b/tips/_schema.json @@ -0,0 +1,39 @@ +{ + "definitions": {}, + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://example.com/object1655988771.json", + "title": "Root", + "type": "object", + "required": [ + "name", + "tips" + ], + "properties": { + "name": { + "$id": "#root/name", + "title": "Name", + "type": "string", + "default": "", + "examples": [ + "Tips category" + ], + "pattern": "^.*$" + }, + "tips": { + "$id": "#root/tips", + "title": "Tips", + "type": "array", + "default": [], + "items":{ + "$id": "#root/tips/items", + "title": "Items", + "type": "string", + "default": "", + "examples": [ + "Some interesting tip" + ], + "pattern": "^.*$" + } + } + } +}