{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://w3id.org/modavis/vao/0.5.0/schema/zenodo-metadata.json",
  "title": "VAO 0.5.0 legacy Zenodo Depositions API metadata projection",
  "description": "A compatibility binding around the legacy Zenodo Depositions API metadata object. It is not a schema for the current InvenioRDM records API or the Zenodo web deposit form.",
  "type": "object",
  "required": [
    "$schema",
    "type",
    "formatVersion",
    "targetAPIProfile",
    "releaseId",
    "publicationRecordId",
    "recordRole",
    "metadata"
  ],
  "properties": {
    "$schema": {
      "const": "https://w3id.org/modavis/vao/0.5.0/schema/zenodo-metadata.json"
    },
    "type": {
      "const": "VAOZenodoMetadata"
    },
    "formatVersion": {
      "const": "0.5.0"
    },
    "targetAPIProfile": {
      "const": "https://developers.zenodo.org/#deposition-metadata"
    },
    "releaseId": {
      "$ref": "#/$defs/id"
    },
    "publicationRecordId": {
      "$ref": "#/$defs/id"
    },
    "recordRole": {
      "enum": [
        "monolithic-root",
        "family-root",
        "family-member"
      ]
    },
    "metadata": {
      "$ref": "#/$defs/metadata"
    }
  },
  "additionalProperties": false,
  "$defs": {
    "id": {
      "type": "string",
      "pattern": "^(urn:|https?:)[^\\s]+$"
    },
    "person": {
      "type": "object",
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "affiliation": {
          "type": "string",
          "minLength": 1
        },
        "orcid": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{4}-\\d{4}-[\\dX]{4}$"
        },
        "gnd": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false
    },
    "contributor": {
      "type": "object",
      "required": [
        "name",
        "type"
      ],
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1
        },
        "affiliation": {
          "type": "string",
          "minLength": 1
        },
        "orcid": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{4}-\\d{4}-[\\dX]{4}$"
        },
        "gnd": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "enum": [
            "ContactPerson",
            "DataCollector",
            "DataCurator",
            "DataManager",
            "Distributor",
            "Editor",
            "HostingInstitution",
            "Producer",
            "ProjectLeader",
            "ProjectManager",
            "ProjectMember",
            "RegistrationAgency",
            "RegistrationAuthority",
            "RelatedPerson",
            "Researcher",
            "ResearchGroup",
            "RightsHolder",
            "Supervisor",
            "Sponsor",
            "WorkPackageLeader",
            "Other"
          ]
        }
      },
      "additionalProperties": false
    },
    "relatedIdentifier": {
      "type": "object",
      "required": [
        "identifier",
        "relation"
      ],
      "properties": {
        "identifier": {
          "type": "string",
          "minLength": 1
        },
        "relation": {
          "enum": [
            "isCitedBy",
            "cites",
            "isSupplementTo",
            "isSupplementedBy",
            "isContinuedBy",
            "continues",
            "isDescribedBy",
            "describes",
            "hasMetadata",
            "isMetadataFor",
            "isNewVersionOf",
            "isPreviousVersionOf",
            "isPartOf",
            "hasPart",
            "isReferencedBy",
            "references",
            "isDocumentedBy",
            "documents",
            "isCompiledBy",
            "compiles",
            "isVariantFormOf",
            "isOriginalFormof",
            "isIdenticalTo",
            "isAlternateIdentifier",
            "isReviewedBy",
            "reviews",
            "isDerivedFrom",
            "isSourceOf",
            "requires",
            "isRequiredBy",
            "isObsoletedBy",
            "obsoletes"
          ]
        },
        "resource_type": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false
    },
    "subject": {
      "type": "object",
      "required": [
        "term",
        "identifier",
        "scheme"
      ],
      "properties": {
        "term": {
          "type": "string",
          "minLength": 1
        },
        "identifier": {
          "type": "string",
          "minLength": 1
        },
        "scheme": {
          "type": "string",
          "minLength": 1
        }
      },
      "additionalProperties": false
    },
    "date": {
      "type": "object",
      "required": [
        "start",
        "type"
      ],
      "properties": {
        "start": {
          "type": "string",
          "minLength": 4
        },
        "end": {
          "type": "string",
          "minLength": 4
        },
        "type": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "metadata": {
      "type": "object",
      "required": [
        "upload_type",
        "title",
        "description",
        "creators",
        "publication_date",
        "version",
        "access_right",
        "keywords",
        "related_identifiers"
      ],
      "properties": {
        "upload_type": {
          "const": "dataset"
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "description": {
          "type": "string",
          "minLength": 1
        },
        "creators": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/person"
          }
        },
        "contributors": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/contributor"
          }
        },
        "publication_date": {
          "type": "string",
          "format": "date"
        },
        "version": {
          "type": "string",
          "minLength": 1
        },
        "access_right": {
          "enum": [
            "open",
            "embargoed",
            "restricted",
            "closed"
          ]
        },
        "license": {
          "type": "string",
          "minLength": 1
        },
        "embargo_date": {
          "type": "string",
          "format": "date"
        },
        "access_conditions": {
          "type": "string",
          "minLength": 1
        },
        "keywords": {
          "type": "array",
          "minItems": 3,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "minLength": 1
          },
          "contains": {
            "const": "Virtual Acoustic Object"
          }
        },
        "related_identifiers": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/relatedIdentifier"
          }
        },
        "communities": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "identifier"
            ],
            "properties": {
              "identifier": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false
          }
        },
        "grants": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "id"
            ],
            "properties": {
              "id": {
                "type": "string",
                "minLength": 1
              }
            },
            "additionalProperties": false
          }
        },
        "references": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          }
        },
        "subjects": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/subject"
          }
        },
        "dates": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/date"
          }
        },
        "language": {
          "type": "string",
          "minLength": 2
        },
        "notes": {
          "type": "string"
        },
        "method": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "allOf": [
        {
          "if": {
            "properties": {
              "access_right": {
                "enum": [
                  "open",
                  "embargoed"
                ]
              }
            },
            "required": [
              "access_right"
            ]
          },
          "then": {
            "required": [
              "license"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "access_right": {
                "const": "embargoed"
              }
            },
            "required": [
              "access_right"
            ]
          },
          "then": {
            "required": [
              "embargo_date"
            ]
          }
        },
        {
          "if": {
            "properties": {
              "access_right": {
                "const": "restricted"
              }
            },
            "required": [
              "access_right"
            ]
          },
          "then": {
            "required": [
              "access_conditions"
            ]
          }
        }
      ]
    }
  }
}
