{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://eljefedelrodeo.humans.airdress.co/data/spectrum/v1/schema.json",
  "title": "spectrum/v1: one jurisdiction's frequency allocation table",
  "description": "Source wording is kept unchanged in use, service, category and conditions. itu_service, primary, footnotes, group, use_en and aliases are editorial additions. Frequencies are in Hz; ranges are [lo, hi).",
  "type": "object",
  "required": [
    "schema",
    "jurisdiction",
    "groups",
    "entries",
    "applications"
  ],
  "properties": {
    "schema": {
      "const": "spectrum/v1"
    },
    "jurisdiction": {
      "type": "object",
      "required": [
        "code",
        "name",
        "authority",
        "document",
        "edition",
        "edition_label",
        "source_url",
        "language",
        "attribution",
        "legal_notice"
      ],
      "properties": {
        "code": {
          "type": "string",
          "pattern": "^[a-z]{2}$",
          "description": "ISO 3166-1 alpha-2, lower case"
        },
        "name": {
          "type": "string"
        },
        "authority": {
          "type": "string"
        },
        "document": {
          "type": "string"
        },
        "edition": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}$"
        },
        "edition_label": {
          "type": "string"
        },
        "source_url": {
          "type": "string",
          "format": "uri"
        },
        "language": {
          "type": "string",
          "description": "BCP 47 language of the source wording"
        },
        "attribution": {
          "type": "string"
        },
        "legal_notice": {
          "type": "string"
        },
        "applications_label": {
          "type": [
            "string",
            "null"
          ]
        },
        "labels": {
          "type": "object",
          "description": "The source's own words for the parts of an entry, for display",
          "properties": {
            "document": {
              "type": [
                "string",
                "null"
              ]
            },
            "entry": {
              "type": [
                "string",
                "null"
              ]
            },
            "service": {
              "type": [
                "string",
                "null"
              ]
            },
            "use": {
              "type": [
                "string",
                "null"
              ]
            },
            "users": {
              "type": [
                "string",
                "null"
              ]
            },
            "footnotes": {
              "type": [
                "string",
                "null"
              ]
            },
            "revised": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        }
      }
    },
    "groups": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "key",
          "label",
          "color"
        ],
        "properties": {
          "key": {
            "type": "string"
          },
          "label": {
            "type": "string"
          },
          "label_source": {
            "type": [
              "string",
              "null"
            ],
            "description": "The group's name in the source language, where it differs"
          },
          "color": {
            "type": "string",
            "pattern": "^#[0-9a-f]{6}$"
          },
          "ink": {
            "type": "string",
            "pattern": "^#[0-9a-f]{6}$"
          }
        }
      }
    },
    "entries": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/entry"
      }
    },
    "applications": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/application"
      }
    }
  },
  "$defs": {
    "range": {
      "type": "object",
      "required": [
        "id",
        "lo",
        "hi",
        "group"
      ],
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[a-z]{2}:"
        },
        "lo": {
          "type": "number",
          "minimum": 0
        },
        "hi": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "use": {
          "type": [
            "string",
            "null"
          ],
          "description": "The source's wording for the use"
        },
        "use_en": {
          "type": [
            "string",
            "null"
          ],
          "description": "Editorial English gloss of use"
        },
        "aliases": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Editorial search names, e.g. LoRa"
        },
        "group": {
          "type": "string"
        },
        "conditions": {
          "type": [
            "string",
            "null"
          ],
          "description": "Source wording: channel spacing, power, duplex and so on"
        },
        "ext": {
          "type": "object",
          "description": "Fields specific to this jurisdiction's source"
        }
      }
    },
    "entry": {
      "allOf": [
        {
          "$ref": "#/$defs/range"
        }
      ],
      "required": [
        "ref",
        "service",
        "itu_service",
        "primary",
        "footnotes",
        "users",
        "revised"
      ],
      "properties": {
        "ref": {
          "type": "string",
          "description": "The source's own entry number"
        },
        "service": {
          "type": [
            "string",
            "null"
          ],
          "description": "Source wording for the radio service"
        },
        "itu_service": {
          "type": [
            "string",
            "null"
          ],
          "description": "ITU Radio Regulations Article 1 service name"
        },
        "primary": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "Primary (true) or secondary (false) allocation, where the source says"
        },
        "footnotes": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "users": {
          "type": "array",
          "items": {
            "enum": [
              "civil",
              "military",
              "federal",
              "non-federal"
            ]
          }
        },
        "revised": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^\\d{4}-\\d{2}$"
        }
      }
    },
    "application": {
      "allOf": [
        {
          "$ref": "#/$defs/range"
        }
      ],
      "description": "Applications that apply across bands, such as Germany's Section 7 (Sonstige Funkanwendungen)",
      "properties": {
        "category": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    }
  }
}
