{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "title": "A Study Schema",
    "description": "Study base schema",
    "type": "object",
    "properties": {
        "alias": {
            "description": "An unique identifier in a submission.",
            "type": "string",
            "minLength": 1
        },
        "title": {
            "description": "Title of the study.",
            "type": "string"
        },
        "description": {
            "description": "More extensive free-form description.",
            "type": "string"
        },
        "attributes": {
            "description": "Attributes for describing a study.",
            "type": "object",
            "properties": {},
            "patternProperties": {
                "^.*$": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                        "type": "object",
                        "properties": {
                            "value": {
                                "type": "string",
                                "minLength": 1
                            },
                            "units": {
                                "type": "string",
                                "minLength": 1
                            },
                            "terms": {
                                "type": "array",
                                "items": {
                                    "type": "object",
                                    "properties": {
                                        "url": {
                                            "type": "string",
                                            "format": "uri"
                                        }
                                    },
                                    "required": [
                                        "url"
                                    ]
                                }
                            }
                        },
                        "required": [
                            "value"
                        ]
                    }
                }
            }
        },
        "StudyDataType": {
            "type": "string",
            "enum": [
                "Sequencing",
                "FunctionalGenomics",
                "Metabolomics",
                "Proteomics"
            ]
        },
        "projectRef": {
            "description": "Reference to project.",
            "$ref": "#/definitions/submittableRef"
        },
        "protocolRefs": {
            "description": "Reference(s) to protocol(s).",
            "type": "array",
            "items": {
                "$ref": "#/definitions/submittableRef"
            }
        }
    },
    "definitions": {
        "submittableRef": {
            "type": "object",
            "properties": {
                "alias": {
                    "type": "string",
                    "minLength": 1
                },
                "accession": {
                    "type": "string",
                    "minLength": 1
                },
                "team": {
                    "type": "string",
                    "minLength": 1
                }
            },
            "oneOf": [
                {
                    "required": [
                        "alias",
                        "team"
                    ]
                },
                {
                    "required": [
                        "accession"
                    ]
                }
            ]
        }
    },
    "required": [
        "alias",
        "StudyDataType"
    ]
}