From 628e5d598eb31929215464bc0b175bb79b92b9bc Mon Sep 17 00:00:00 2001 From: Matthew Chambers Date: Sun, 29 Aug 2021 20:17:07 -0500 Subject: [PATCH] start to JSON schemas for validating JSON files before blowing up GT with invalid stuff --- package.nw/data/acknowledgements.json | 1 + package.nw/data/acknowledgements.schema.json | 26 +++ package.nw/data/awards.json | 1 + package.nw/data/awards.schema.json | 190 +++++++++++++++++++ 4 files changed, 218 insertions(+) create mode 100644 package.nw/data/acknowledgements.schema.json create mode 100644 package.nw/data/awards.schema.json diff --git a/package.nw/data/acknowledgements.json b/package.nw/data/acknowledgements.json index e523949c..13338bbd 100644 --- a/package.nw/data/acknowledgements.json +++ b/package.nw/data/acknowledgements.json @@ -1,4 +1,5 @@ { + "$schema": "./acknowledgements.schema.json", "2M0SYH": { "badge": "img/emojis/money-bag.png", "message": "GridTracker Donor" diff --git a/package.nw/data/acknowledgements.schema.json b/package.nw/data/acknowledgements.schema.json new file mode 100644 index 00000000..fa126b0a --- /dev/null +++ b/package.nw/data/acknowledgements.schema.json @@ -0,0 +1,26 @@ +{ + "$id": "acknowledgements.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "acknowledgements", + "description": "List of everyone that's contributed to GridTracker", + "type": "object", + "patternProperties": { + "[0-9A-Z]{3,10}": { + "type": "object", + "required": [ + "badge", + "message" + ], + "properties": { + "badge": { + "type": "string", + "description": "path and filename of the 'badge' to display by a contributors callsign" + }, + "message": { + "type": "string", + "description": "the message displayed to say how a person contributed" + } + } + } + } +} \ No newline at end of file diff --git a/package.nw/data/awards.json b/package.nw/data/awards.json index 7e5e049e..7d37b511 100644 --- a/package.nw/data/awards.json +++ b/package.nw/data/awards.json @@ -1,4 +1,5 @@ { + "$schema": "./awards.schema.json", "ARRL": { "awards": { "DXCC": { diff --git a/package.nw/data/awards.schema.json b/package.nw/data/awards.schema.json new file mode 100644 index 00000000..fe401e02 --- /dev/null +++ b/package.nw/data/awards.schema.json @@ -0,0 +1,190 @@ +{ + "$id": "awards.schema.json", + "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "List of awards by sponsor and programmatic definitions of each", + "patternProperties": { + "[0-9A-Z]{3,10}": { + "title": "Awards Tracker Definitions", + "type": "object", + "required": [ + "awards", + "compiledBy", + "mixed", + "qsl_req", + "sponsor", + "website" + ], + "awards": { + "description": "A list of awards from this sponsor with a programmatic description of each", + "type": "object", + "patternProperties": { + "[0-9A-Z]{3,10}": { + "title": "Awards", + "type": "object", + "required": [ + "name", + "rule", + "sponsor", + "tooltip" + ], + "name": { + "type": "string", + "description": "Full name of the award" + }, + "rule": { + "type": "object", + "description": "Award rules", + "properties": { + "band": { + "type": "array", + "description": "Array of bands this award is valid for, or single array value mixed", + "items": { + "type": "string", + "enum": [ + "Mixed", + "160m", + "80m", + "60m", + "40m", + "30m", + "20m", + "17m", + "15m", + "12m", + "11m", + "10m", + "6m", + "4m", + "2m", + "1.25m", + "70cm", + "33cm", + "23cm" + ] + } + }, + "call": { + "type": "array", + "description": "Array of valid callsigns needed to work for award", + "items": { + "type": "string" + } + }, + "count": { + "type": "array", + "description": "Array of the count of type that is needed for this award", + "items": { + "type": "integer" + } + }, + "dxcc": { + "type": "array", + "description": "DXCC entity by ARRL DXCC entity number that are valid for award", + "items": { + "type": "integer" + } + }, + "endorse": { + "type": "array", + "description": "Array of bands to that count as single band endorsements (if any)", + "items": { + "type": "string", + "enum": [ + "Mixed", + "160m", + "80m", + "60m", + "40m", + "30m", + "20m", + "17m", + "15m", + "12m", + "11m", + "10m", + "6m", + "4m", + "2m", + "1.25m", + "70cm", + "33cm", + "23cm" + ] + } + }, + "mode": { + "type": "array", + "description": "Array of modes valid for award", + "items": { + "type": "string", + "enum": [ + "Mixed", + "CW", + "Digital", + "Phone" + ] + } + }, + "type": { + "type": "string", + "description": "The type of award", + "enum": [ + "call", + "callarea", + "calls2band", + "calls2dxcc", + "cnty", + "cont", + "cont2band", + "cont5", + "cont52band", + "count", + "dxcc", + "dxcc2band", + "grids", + "mode", + "state", + "states2band" + ] + }, + "unique": { + "type": "integer", + "description": "Number of uniques that is required" + } + } + }, + "sponsor": { + "type": "string", + "description": "Short name of award sponsor" + }, + "tooltip": { + "type": "string", + "description": "Text for award tracker tooltip" + } + } + } + }, + "compiledBy": { + "description": "The name/callsign of the custodian of this award sponsor data", + "type": "string" + }, + "mixed": { + "description": "List of bands considered for 'mixed band' of each award", + "items": {}, + "type": "array" + }, + "qsl_req": { + "description": "Do contacts have to be QSL'd and if so how to qualify for this award sponsor", + "type": "string" + }, + "sponsor": { + "description": "Full proper name of awards sponsor", + "type": "string" + }, + "website": { + "description": "The URI of the awards sponsor's official website", + "type": "uri" + } + } + } +} \ No newline at end of file