diff --git a/.github/workflows/json_validate.yml b/.github/workflows/json_validate.yml new file mode 100644 index 000000000..92b0401ef --- /dev/null +++ b/.github/workflows/json_validate.yml @@ -0,0 +1,14 @@ +name: Validate JSONs + +on: [push, pull_request] + +jobs: + verify-json-validation: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Validate JSON + uses: docker://orrosenblatt/validate-json-action:latest + env: + INPUT_SCHEMA: ./schema.json + INPUT_JSONS: custom_components/battery_notes/data/library.json diff --git a/schema.json b/schema.json new file mode 100644 index 000000000..5c5d99b0c --- /dev/null +++ b/schema.json @@ -0,0 +1,41 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://github.com/andrew-codechimp/HA-Battery-Notes.schema.json", + "title": "Battery Notes Library", + "description": "Library of battery types for devices", + "type": "object", + "properties": { + "version": { + "description": "Version of the library schema", + "type": "integer" + }, + "devices": { + "type": "array", + "properties": { + "manufacturer": { + "type": "string" + }, + "model": { + "type": "string" + }, + "battery_type": { + "type": "string" + }, + "battery_quantity": { + "type": "integer" + } + }, + "additionalProperties": false, + "required": [ + "manufacturer", + "model", + "battery_type" + ] + } + }, + "additionalProperties": false, + "required": [ + "version", + "devices" + ] +} \ No newline at end of file