{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "Keep Schema",
    "description": "A list of castles or fortifications.",
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "id": {
                "description": "The unique identifier (UUID v7) of the castle or fortification.",
                "type": "string",
                "format": "uuid"
            },
            "name": {
                "description": "The name of the castle or fortification.",
                "type": "string"
            },
            "country": {
                "description": "The country of the castle or fortification.",
                "$ref": "#/definitions/country"
            },
            "region": {
                "description": "The region of the castle or fortification (this is only relevant for UK castles).",
                "$ref": "#/definitions/region"
            },
            "coordinates": {
                "description": "The coordinates of the castle or fortification.",
                "$ref": "#/definitions/coordinates"
            },
            "accessible": {
                "description": "Whether the castle or fortification is accessible to the public.",
                "type": "boolean"
            },
            "alternativeNames": {
                "$comment": "Use an English version if available, for non-English names include the translation in brackets.",
                "description": "The alternative names of the castle or fortification.",
                "type": "array",
                "items": {
                    "type": "string"
                }
            },
            "built": {
                "description": "The century or date that the castle or fortification was built.",
                "type": "string",
                "pattern": "^(?:\\d{1,4}|\\d{1,4} BCE|(?:\\d{1,2}|\\d{1,2}-\\d{1,2})(?:st|nd|rd|th) Century|(?:\\d{1,2}|\\d{1,2}-\\d{1,2})(?:st|nd|rd|th) Century BCE)$"
            },
            "condition": {
                "description": "The condition of the castle or fortification.",
                "$ref": "#/definitions/condition"
            },
            "description": {
                "description": "The description of the castle or fortification.",
                "type": "string"
            },
            "homepage": {
                "$comment": "Use an English version if available.",
                "description": "The official homepage of the castle or fortification.",
                "type": "string",
                "format": "uri-reference"
            },
            "ownedBy": {
                "description": "The owner of the castle or fortification.",
                "type": "string"
            },
            "type": {
                "description": "The type of the castle or fortification.",
                "$ref": "#/definitions/type"
            }
        },
        "required": [
            "id",
            "name",
            "country",
            "coordinates",
            "built",
            "condition",
            "ownedBy",
            "type"
        ],
        "additionalProperties": false
    },
    "definitions": {
        "coordinates": {
            "description": "A set of coordinates in the form of latitude and longitude.",
            "type": "object",
            "properties": {
                "latitude": {
                    "description": "The latitude of the coordinates to a maximum of 5 decimal places (within 1.11m accuracy).",
                    "type": "number"
                },
                "longitude": {
                    "description": "The longitude of the coordinates to a maximum of 5 decimal places (within 1.11m accuracy).",
                    "type": "number"
                }
            },
            "required": [
                "latitude",
                "longitude"
            ],
            "examples": [
                {
                    "latitude": 51.48389,
                    "longitude": -0.60440
                }
            ]
        },
        "type": {
            "description": "The type of a castle or fortification.",
            "enum": [
                "Artillery Fort",
                "Concentric",
                "Folly",
                "Fort",
                "Fortified Manor House",
                "Keepless",
                "Motte and Bailey",
                "Palace",
                "Round Keep",
                "Shell Keep",
                "Square Keep",
                "Tower House",
                "Unknown"
            ]
        },
        "condition": {
            "description": "The condition of a castle or fortification.",
            "enum": [
                "Earthworks",
                "Fragmented Remains",
                "Intact",
                "No Visible Remains",
                "Partial Ruins",
                "Partially Restored",
                "Rebuilt",
                "Restored",
                "Ruins"
            ]
        },
        "country": {
            "$comment": "See https://www.iso.org/iso-3166-country-codes.html for more information.",
            "description": "An ISO 3166 identifier for a country.",
            "enum": [
                "AD",
                "AE",
                "AF",
                "AG",
                "AI",
                "AL",
                "AM",
                "AO",
                "AQ",
                "AR",
                "AS",
                "AT",
                "AU",
                "AW",
                "AX",
                "AZ",
                "BA",
                "BB",
                "BD",
                "BE",
                "BF",
                "BG",
                "BH",
                "BI",
                "BJ",
                "BL",
                "BM",
                "BN",
                "BO",
                "BQ",
                "BR",
                "BS",
                "BT",
                "BV",
                "BW",
                "BY",
                "BZ",
                "CA",
                "CC",
                "CD",
                "CF",
                "CG",
                "CH",
                "CI",
                "CK",
                "CL",
                "CM",
                "CN",
                "CO",
                "CR",
                "CU",
                "CV",
                "CW",
                "CX",
                "CY",
                "CZ",
                "DE",
                "DJ",
                "DK",
                "DM",
                "DO",
                "DZ",
                "EC",
                "EE",
                "EG",
                "EH",
                "ER",
                "ES",
                "ET",
                "FI",
                "FJ",
                "FK",
                "FM",
                "FO",
                "FR",
                "GA",
                "GB",
                "GD",
                "GE",
                "GF",
                "GG",
                "GH",
                "GI",
                "GL",
                "GM",
                "GN",
                "GP",
                "GQ",
                "GR",
                "GS",
                "GT",
                "GU",
                "GW",
                "GY",
                "HK",
                "HM",
                "HN",
                "HR",
                "HT",
                "HU",
                "ID",
                "IE",
                "IL",
                "IM",
                "IN",
                "IO",
                "IQ",
                "IR",
                "IS",
                "IT",
                "JE",
                "JM",
                "JO",
                "JP",
                "KE",
                "KG",
                "KH",
                "KI",
                "KM",
                "KN",
                "KP",
                "KR",
                "KW",
                "KY",
                "KZ",
                "LA",
                "LB",
                "LC",
                "LI",
                "LK",
                "LR",
                "LS",
                "LT",
                "LU",
                "LV",
                "LY",
                "MA",
                "MC",
                "MD",
                "ME",
                "MF",
                "MG",
                "MH",
                "MK",
                "ML",
                "MM",
                "MN",
                "MO",
                "MP",
                "MQ",
                "MR",
                "MS",
                "MT",
                "MU",
                "MV",
                "MW",
                "MX",
                "MY",
                "MZ",
                "NA",
                "NC",
                "NE",
                "NF",
                "NG",
                "NI",
                "NL",
                "NO",
                "NP",
                "NR",
                "NU",
                "NZ",
                "OM",
                "PA",
                "PE",
                "PF",
                "PG",
                "PH",
                "PK",
                "PL",
                "PM",
                "PN",
                "PR",
                "PS",
                "PT",
                "PW",
                "PY",
                "QA",
                "RE",
                "RO",
                "RS",
                "RU",
                "RW",
                "SA",
                "SB",
                "SC",
                "SD",
                "SE",
                "SG",
                "SH",
                "SI",
                "SJ",
                "SK",
                "SL",
                "SM",
                "SN",
                "SO",
                "SR",
                "SS",
                "ST",
                "SV",
                "SX",
                "SY",
                "SZ",
                "TC",
                "TD",
                "TF",
                "TG",
                "TH",
                "TJ",
                "TK",
                "TL",
                "TM",
                "TN",
                "TO",
                "TR",
                "TT",
                "TV",
                "TZ",
                "UA",
                "UG",
                "UM",
                "US",
                "UY",
                "UZ",
                "VA",
                "VC",
                "VE",
                "VG",
                "VI",
                "VN",
                "VU",
                "WF",
                "WS",
                "YE",
                "YT",
                "ZA",
                "ZM",
                "ZW"
            ]
        },
        "region": {
            "$comment": "See https://wikipedia.org/wiki/ISO_3166-2:GB#Other_codes for more information.",
            "description": "A BS 6879 identifier for a region.",
            "enum": [
                "GB-ENG",
                "GB-NIR",
                "GB-SCT",
                "GB-WLS"
            ]
        }
    }
}
