{
  "swagger": "2.0",
  "info": {
    "version": "0.0.1",
    "title": "Tree DB"
  },
  "host": "www.genetrees.org",
  "basePath": "/api/v1",
  "schemes": [
    "https"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "paths": {
    "/docs": {
      "get": {
        "summary": "Web site describing this API",
        "tags": [
          "API Documentation"
        ],
        "responses": {
          "200": {
            "description": "HTML documentation for this web service, powered by swagger."
          }
        }
      }
    },
    "/sets": {
      "get": {
        "tags": [
          "sets"
        ],
        "description": "Returns a list of sets of trees",
        "operationId": "getSets",
        "parameters": [
          {
            "in": "query",
            "name": "q",
            "type": "string",
            "description": "try 'platform:compara'"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/SetsResponse"
              }
            }
          },
          "default": {
            "description": "Error",
            "schema": {
              "$ref": "#/definitions/ErrorResponse"
            }
          }
        }
      }
    },
    "/search": {
      "get": {
        "tags": [
          "search"
        ],
        "description": "Returns a list of trees matching the search criteria in the given set",
        "operationId": "search",
        "parameters": [
          {
            "name": "setId",
            "in": "query",
            "type": "string",
            "description": "try 'compara_pan_91'",
            "required": true
          },
          {
            "name": "q",
            "in": "query",
            "type": "string",
            "description": "try 'geneId:AT1G32900'"
          },
          {
            "name": "rows",
            "in": "query",
            "type": "number",
            "description": "number of rows",
            "default": 10
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "schema": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/SearchResponse"
              }
            }
          },
          "default": {
            "description": "Error",
            "schema": {
              "$ref": "#/definitions/ErrorResponse"
            }
          }
        }
      }
    },
    "/tree": {
      "get": {
        "tags": [
          "tree"
        ],
        "description": "Return the requested tree",
        "operationId": "getTree",
        "parameters": [
          {
            "name": "setId",
            "in": "query",
            "description": "Identifier for the tree set",
            "required": true,
            "type": "string"
          },
          {
            "name": "treeId",
            "in": "query",
            "description": "Identifier for the tree",
            "required": true,
            "type": "string"
          },
          {
            "name": "filter",
            "in": "query",
            "description": "filter on leaf nodes",
            "type": "string",
            "required": false
          },
          {
            "name": "subtree",
            "in": "query",
            "description": "fetch a subtree rooted at this node",
            "required": false,
            "type": "integer"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "schema": {
              "$ref": "#/definitions/TreeResponse"
            }
          },
          "default": {
            "description": "Error",
            "schema": {
              "$ref": "#/definitions/ErrorResponse"
            }
          }
        }
      }
    },
    "/neighbors": {
      "get": {
        "tags": [
          "neighbors"
        ],
        "description": "Return the neighbors of genes in a tree",
        "operationId": "getNeighbors",
        "parameters": [
          {
            "name": "setId",
            "in": "query",
            "description": "Identifier for the tree set",
            "required": true,
            "type": "string"
          },
          {
            "name": "treeId",
            "in": "query",
            "description": "Identifier for the tree",
            "required": true,
            "type": "string"
          },
          {
            "name": "filter",
            "in": "query",
            "description": "filter on leaf nodes",
            "type": "string",
            "required": false
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "schema": {
              "$ref": "#/definitions/NeighborsResponse"
            }
          },
          "default": {
            "description": "Error",
            "schema": {
              "$ref": "#/definitions/ErrorResponse"
            }
          }
        }
      }
    },
    "/swagger": {}
  },
  "definitions": {
    "SetsResponse": {
      "required": [
        "setId"
      ],
      "properties": {
        "setId": {
          "type": "string"
        }
      }
    },
    "SearchResponse": {
      "required": [
        "treeId"
      ],
      "properties": {
        "treeId": {
          "type": "string"
        }
      }
    },
    "NeighborsResponse": {
      "type": "object"
    },
    "TreeResponse": {
      "allOf": [
        {
          "$ref": "#/definitions/TreeNode"
        },
        {
          "required": [
            "treeId"
          ],
          "properties": {
            "treeId": {
              "type": "string"
            }
          }
        }
      ]
    },
    "TreeNode": {
      "allOf": [
        {
          "$ref": "#/definitions/TreeInternalNode"
        },
        {
          "$ref": "#/definitions/TreeLeafNode"
        },
        {
          "required": [
            "nodeId"
          ],
          "properties": {
            "nodeId": {
              "type": "integer",
              "minimum": 0
            },
            "distanceToParent": {
              "type": "number",
              "minimum": 0
            }
          }
        }
      ]
    },
    "TreeInternalNode": {
      "properties": {
        "nodeType": {
          "type": "string"
        },
        "bootstrap": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "duplicationConfidenceScore": {
          "type": "number"
        },
        "children": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/TreeNode"
          }
        }
      }
    },
    "TreeLeafNode": {
      "properties": {
        "geneId": {
          "type": "string"
        },
        "geneDescription": {
          "type": "string"
        },
        "sequence": {
          "type": "string"
        },
        "cigar": {
          "type": "string"
        }
      }
    },
    "ErrorResponse": {
      "required": [
        "message"
      ],
      "properties": {
        "message": {
          "type": "string"
        }
      }
    }
  }
}