{
  "description": "JSON schema for COL Data Package (ColDP) metadata",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/CatalogueOfLife/coldp/master/metadata.json",
  "type": "object",
  "properties": {
        "doi": {
          "$ref": "#/definitions/doi"
        },
        "identifier": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "title": {
          "type": "string"
        },
        "alias": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "issued": {
          "$ref": "#/definitions/isodate"
        },

        "creator": {
          "items": {
            "$ref": "#/definitions/Agent"
          },
          "type": "array"
        },
        "editor": {
          "items": {
            "$ref": "#/definitions/Agent"
          },
          "type": "array"
        },
        "publisher": {
          "$ref": "#/definitions/Agent"
        },
        "contact": {
          "$ref": "#/definitions/Agent"
        },
        "contributor": {
          "items": {
            "$ref": "#/definitions/Agent"
          },
          "type": "array"
        },

        "description": {
          "type": "string"
        },

        "keyword": {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        "taxonomicScope": {
          "type": "string"
        },
        "temporalScope": {
          "type": "string"
        },
        "geographicScope": {
          "type": "string"
        },

        "completeness": {
          "type": "integer"
        },
        "confidence": {
          "type": "integer"
        },
        "url": {
          "format": "uri",
          "type": "string"
        },
        "feedbackUrl": {
          "format": "uri",
          "type": "string"
        },
        "urlFormatter": {
          "type": "object",
          "properties": {
              "name": {"type": "string"},
              "taxon": {"type": "string"},
              "synonym": {"type": "string"},
              "reference": {"type": "string"},
              "author": {"type": "string"},
              "typeMaterial": {"type": "string"}
          }
        },
        "conversion": {
          "type": "object",
          "properties": {
              "description": {"type": "string"},
              "url": {"type": "string", "format": "uri"}
          }
        },
        "issn": {
          "type": "string"
        },
        "license": {
          "type": "string"
        },
        "logo": {
          "format": "uri",
          "type": "string"
        },
        "source": {
          "items": {
            "$ref": "#/definitions/Citation"
          },
          "type": "array"
        },
        "notes": {
          "type": "string"
        }
  },
  "required": [
    "title",
    "creator",
    "issued",
    "license"
  ],
  "definitions": {
    "Agent": {
      "title": "Agent",
      "type": "object",
      "properties": {
        "orcid": {
          "type": "string"
        },
        "family": {
          "type": "string"
        },
        "given": {
          "type": "string"
        },

        "rorid": {
          "type": "string"
        },
        "department": {
          "type": "string"
        },
        "organisation": {
          "type": "string"
        },

        "city": {
          "type": "string"
        },
        "state": {
          "type": "string"
        },
        "country": {
          "type": "string",
          "minLength": 2,
          "maxLength": 2
        },

        "email": {
          "format": "email",
          "type": "string"
        },
        "url": {
          "format": "uri",
          "type": "string"
        },
        "note": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "anyOf": [
        { "required":[ "family" ] },
        { "required":[ "organisation" ] },
        { "required":[ "email" ] }
      ]
    },
    "Citation": {
      "additionalProperties": true,
      "properties": {
        "id": {
          "type": "string"
        },
        "type": {
          "type": "string",
          "enum": ["article-journal", "book", "chapter", "thesis", "paper-conference", "manuscript", "dataset", "webpage", "personal_communication"]
        },
        "title": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "author": {
          "items": {
            "$ref": "#/definitions/Person"
          },
          "type": "array"
        },
        "editor": {
          "items": {
            "$ref": "#/definitions/Person"
          },
          "type": "array"
        },
        "publisher": {
          "type": "string"
        },
        "publisherPlace": {
          "type": "string"
        },
        "issued": {
          "$ref": "#/definitions/isodate"
        },
        "containerTitle": {
          "type": "string"
        },
        "containerAuthor": {
          "items": {
            "$ref": "#/definitions/Person"
          },
          "type": "array"
        },
        "volume": {
          "type": "string"
        },
        "issue": {
          "type": "string"
        },
        "edition": {
          "type": "string"
        },
        "page": {
          "type": "string"
        },
        "collectionTitle": {
          "type": "string"
        },
        "collectionEditor": {
          "items": {
            "$ref": "#/definitions/Person"
          },
          "type": "array"
        },
        "doi": {
          "$ref": "#/definitions/doi"
        },
        "isbn": {
          "type": "string"
        },
        "issn": {
          "type": "string"
        },
        "url": {
          "format": "uri",
          "type": "string"
        },
        "accessed": {
          "$ref": "#/definitions/doi"
        },

        "note": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "title"
      ],
      "title": "Source",
      "type": "object"
    },
    "Person": {
      "title": "Person",
      "type": "object",
      "properties": {
        "family": {
          "type": "string"
        },
        "given": {
          "type": "string"
        },
        "literal": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "isodate": {
      "title": "ISO Date",
      "type": "string",
      "format": "regex",
      "pattern": "^[12][0-9][0-9][0-9](-[01][0-9](-[0123][0-9])?)?$"
    },
    "doi": {
      "title": "DOI",
      "type": "string",
      "format": "regex",
      "pattern": "^(doi:|https://doi.org/)?10.[0-9]+/.+"
    }

  }
}