{
    "$schema": "http://json-schema.org/draft-04/schema",
    "description": "Graph data description. Please note that all field keys are to be lowercase and use snake-case (e.g. words are separated by underscores like ncbi_tax_id). Some of the metadata fields are not required but are included as exemplars for generating interoperable BEL JGF files.  You may need to provide additional validation programmatically to confirm that the metadata you need for your application exists.",
    "oneOf": [
        {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "graph": {
                    "$ref": "#/definitions/graph"
                }
            },
            "required": [
                "graph"
            ]
        },
        {
            "type": "object",
            "additionalProperties": false,
            "properties": {
                "label": {
                    "type": "string",
                    "title": "Graph Set Label",
                    "description": "Graph Set label"
                },
                "type": {
                    "type": "string",
                    "title": "Type of Graphs in Set",
                    "description": "Graph types in graph set"
                },
                "metadata": {
                    "type": [
                        "object",
                        "null"
                    ],
                    "title": "Graph Set Metadata",
                    "description": "Graph set metadata"
                },
                "graphs": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/graph"
                    }
                }
            }
        }
    ],
    "definitions": {
        "graph": {
            "type": "object",
            "additionalProperties": false,
            "title": "Graph or Network data",
            "properties": {
                "label": {
                    "type": "string",
                    "title": "Graph Label",
                    "description": "Graph label"
                },
                "directed": {
                    "type": [
                        "boolean",
                        "null"
                    ],
                    "description": "Directed or undirected graph",
                    "default": true
                },
                "type": {
                    "type": "string",
                    "title": "Type of Graph",
                    "description": "BEL Versioned Graph type"
                },
                "metadata": {
                    "type": [
                        "object",
                        "null"
                    ],
                    "additionalProperties": true,
                    "properties": {
                        "ncbi_tax_id": {
                            "type": "integer",
                            "title": "NCBI Taxonomy ID",
                            "description": "NCBI Taxonomy ID - http://www.ncbi.nlm.nih.gov/taxonomy"
                        },
                        "species_common_name": {
                            "type": "string",
                            "title": "Species Common Name",
                            "description": "Species common name, e.g. human, mouse, rat"
                        },
                        "description": {
                            "type": "string",
                            "title": "Graph description",
                            "description": "Graph description"
                        },
                        "version": {
                            "type": "string",
                            "description": "Version of the graph"
                        },
                        "bel_version": {
                            "type": "string",
                            "title": "BEL Version",
                            "description": "The version of BEL (Biological Expression Language) represented in this graph. This version string conforms to the language version as defined by OpenBEL (i.e. 1.0, 2.0, ...)."
                        }
                    }
                },
                "nodes": {
                    "type": [
                        "array",
                        "null"
                    ],
                    "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "label": {
                                "type": "string"
                            },
                            "metadata": {
                                "type": [
                                    "object",
                                    "null"
                                ],
                                "additionalProperties": true,
                                "properties": {
                                    "coordinate": {
                                        "type": "array",
                                        "items": {
                                            "type": "number"
                                        },
                                        "minItems": 2,
                                        "title": "Node coordinates",
                                        "description": "Node coordinates as either an (x, y) or (x, y, z) tuple, the tuple is unbounded to allow additional dimensions to be used in addition to x, y and z coordinates"
                                    },
                                    "bel_function_type": {
                                        "type": "string",
                                        "description": "BEL function types such as proteinAbundance, trancriptionalActivity, etc"
                                    }
                                }
                            }
                        }
                    },
                    "required": [
                        "id"
                    ]
                },
                "edges": {
                    "type": [
                        "array",
                        "null"
                    ],
                    "items": {
                        "type": "object",
                        "additionalProperties": false,
                        "properties": {
                            "source": {
                                "type": "string",
                                "title": "Source Node",
                                "description": "First node in edge triple"
                            },
                            "target": {
                                "type": "string",
                                "title": "Target Node",
                                "description": "Second node in edge triple"
                            },
                            "relation": {
                                "type": "string",
                                "title": "Edge relationship",
                                "description": "Relationship between nodes in edge - may be directed or undirected"
                            },
                            "directed": {
                                "type": [
                                    "boolean",
                                    "null"
                                ],
                                "default": true
                            },
                            "label": {
                                "type": "string"
                            },
                            "metadata": {
                                "type": [
                                    "object",
                                    "null"
                                ],
                                "additionalProperties": true,
                                "properties": {
                                    "causal": {
                                        "type": "boolean",
                                        "description": "True if a BEL causal edge type"
                                    },
                                    "nanopubs": {
                                        "type": "array",
                                        "items": {
                                            "$ref": "#/definitions/nanopub"
                                        }
                                    }
                                }
                            }
                        },
                        "required": [
                            "source",
                            "target"
                        ]
                    }
                }
            }
        },
        "nanopub": {
            "type": "object",
            "additionalProperties": false,
            "required": ["bel_statement","citation"],
            "properties": {
                "bel_statement": {
                    "type": "string",
                    "title": "BEL Statement",
                    "description": "An OpenBEL.org BEL Statement is an expression that represents knowledge of the existence of biological entities and relationships between them that are known to be observed within a particular context, based on some source of prior knowledge such as a scientific publication or newly generated experimental data."
                },
                "citation": {
                  "type":        "object",
                  "title":       "Citation",
                  "description": "The citation specifies the written source where the biological knowledge was referenced.",
                  "required":    ["type", "id"],
                  "properties": {
                    "type": {
                      "type":        "string",
                      "enum":        ["PubMed", "Book", "Journal", "Online Resource", "Other"],
                      "title":       "Citation Type",
                      "description": "The citation type of the reference."
                    },
                    "id": {
                      "type":        ["string", "number"],
                      "title":       "Citation ID",
                      "description": "The citation identifier (PubMed ID, ISBN, DOI, URL) of the reference."
                    },
                    "name": {
                      "type":        "string",
                      "title":       "Citation Name",
                      "description": "The citation name of the reference."
                    },
                    "date": {
                      "type":        "string",
                      "title":       "Citation Date",
                      "description": "The citation date of the reference."
                    },
                    "authors": {
                      "type":        "array",
                      "title":       "Citation Authors",
                      "description": "The citation authors of the reference.",
                      "items": {
                        "type":     "string",
                        "minItems": 0
                      }
                    },
                    "comment": {
                      "type":        "string",
                      "title":       "Citation Comment",
                      "description": "The citation comment of the reference."
                    }
                  }
                },
                "support": {
                    "type":        ["string", "null"],
                    "title":       "Support",
                    "description": "Abstract from source text to provide support for this BEL Nanopub."
                },
                "experiment_context": {
                    "type":        ["array", "null"],
                    "title":       "Experiment Context",
                    "description": "An experiment context specifies the experiment's parameters where this interaction was observed.",
                    "additionalProperties": false,
                    "items": {
                        "type":       "object",
                        "required":   ["name", "value"],
                        "properties": {
                          "name": {
                            "type":        "string",
                            "title":       "Annotation Type",
                            "description": "Annotation type listing - sourced from the BEL Annotation resource names"
                          },
                          "value": {
                            "type":        ["string", "number", "boolean", "array"],
                            "title":       "Annotations",
                            "description": "Annotations such as Homo sapiens, cancer, epithelial tissue sourced from the BEL Annotation resources",
                            "items": {
                              "type": ["string", "number", "boolean"]
                            }
                          },
                          "uri": {
                            "type":        "string",
                            "title":       "Annotation URI",
                            "description": "URI for Annotation",
                            "format":      "uri",
                            "items": {
                              "type":   "string",
                              "format": "uri"
                            }
                          }
                        }
                    }
                },
                "references": {
                    "type": ["object", "null"],
                    "title": "References",
                    "description": "The references section identifies annotation and namespace URIs.",
                    "properties": {
                        "annotations": {
                            "type": ["array", "null"],
                            "title": "Annotation references",
                            "description": "References to annotation resources.",
                            "item": {
                                "type": "object",
                                "properties": {
                                    "keyword": {
                                        "type": "string",
                                        "title": "Keyword",
                                        "description": "Keyword that identifies this annotation resource, but only in the context of this BEL Nanopub."
                                    },
                                    "uri": {
                                        "type": "string",
                                        "format": "uri",
                                        "title": "URI",
                                        "description": "URI that identifies this annotation resource."
                                    }
                                },
                                "required": ["keyword", "uri"]
                            }
                        },
                        "namespaces": {
                            "type": ["array", "null"],
                            "title": "Namespace references",
                            "description": "References to namespace resources.",
                            "item": {
                                "type": "object",
                                "properties": {
                                    "keyword": {
                                        "type": "string",
                                        "title": "Keyword",
                                        "description": "Keyword that identifies this namespace resource, but only in the context of this BEL Nanopub."
                                    },
                                    "uri": {
                                        "type": "string",
                                        "format": "uri",
                                        "title": "URI",
                                        "description": "URI that identifies this namespace resource."
                                    }
                                },
                                "required": ["keyword", "uri"]
                            }
                        }
                    }
                },
                "metadata": {
                    "type": ["array", "null"],
                    "title": "BEL Nanopub metadata",
                    "description": "Metadata that describes the BEL Nanopub.",
                    "items": {
                        "oneOf": [{
                            "type": "object",
                            "required": ["name", "value"],
                            "properties": {
                                "name": {
                                    "type": "string",
                                    "title": "Name",
                                    "description": "The name of this metadata property."
                                },
                                "value": {
                                    "type": ["array", "boolean", "number", "object", "string"],
                                    "title": "Value",
                                    "description": "The value of this metadata property.",
                                    "items": {
                                        "type": ["array", "boolean", "integer", "number", "null", "object", "string"]
                                    }
                                }
                            }
                        }, {
                            "type": "object",
                            "required": ["uri"],
                            "title": "Annotation URI(s)",
                            "description": "URI(s) for Annotations",
                            "properties": {
                                "uri": {
                                    "type": ["string", "array"],
                                    "format": "uri",
                                    "items": {
                                        "type": "string",
                                        "format": "uri"
                                    }
                                }
                            }
                        }]
                    }
                }
            }
        }
    }
}
