{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://aij.eddy3d.com/api/schemas/case.schema.json",
 "title": "Case",
 "description": "One case in full: configuration, frame, units, inflow, point-table summary, geometry, validation status, known data issues and attribution.",
 "type": "object",
 "required": [
  "$schema",
  "schema_version",
  "data_version",
  "license",
  "id",
  "title",
  "frame",
  "units",
  "approach_flow",
  "points",
  "geometry",
  "validation",
  "known_issues",
  "people",
  "citation"
 ],
 "properties": {
  "$schema": {
   "type": "string",
   "format": "uri"
  },
  "schema_version": {
   "type": "string",
   "pattern": "^\\d+\\.\\d+\\.\\d+$",
   "description": "the API's version (semantic versioning); see index.json changelog"
  },
  "data_version": {
   "type": "string",
   "pattern": "^[0-9a-f]{64}$",
   "description": "SHA-256 over every served measurement, geometry and score file; changes when, and only when, the data does"
  },
  "license": {
   "const": "CC-BY-4.0",
   "description": "SPDX identifier of the data's licence"
  },
  "id": {
   "enum": [
    "A",
    "B",
    "C",
    "D",
    "E",
    "F",
    "G",
    "H",
    "I",
    "J",
    "K",
    "L",
    "M"
   ]
  },
  "slug": {
   "type": "string"
  },
  "title": {
   "type": "string"
  },
  "summary": {
   "type": "string"
  },
  "configuration": {
   "type": "object"
  },
  "configurations": {
   "type": "array",
   "items": {
    "type": "object"
   }
  },
  "quantities": {
   "type": "array",
   "items": {
    "type": "string"
   }
  },
  "units": {
   "type": "object"
  },
  "frame": {
   "type": "object",
   "required": [
    "origin",
    "x",
    "y",
    "z"
   ],
   "properties": {
    "origin": {
     "type": "string"
    },
    "x": {
     "type": "string"
    },
    "y": {
     "type": "string"
    },
    "z": {
     "type": "string"
    }
   }
  },
  "inflow_fit": {
   "type": "object"
  },
  "inflow": {
   "type": "object",
   "required": [
    "benchmark_data",
    "recommended",
    "flow_direction"
   ],
   "properties": {
    "benchmark_data": {
     "type": "object",
     "description": "the measured approach flow and the fit of it: the benchmark's data as cleaned here"
    },
    "recommended": {
     "type": "object",
     "description": "the inlet this repository recommends (its choice, not the benchmark's); `status` says so"
    },
    "flow_direction": {
     "type": "object",
     "required": [
      "convention"
     ],
     "properties": {
      "convention": {
       "enum": [
        "along_x",
        "geographic_x_east_y_north",
        "x_north_y_west"
       ]
      },
      "meaning": {
       "type": "string"
      }
     }
    },
    "eddy3d_runs": {
     "type": "array",
     "items": {
      "type": "object"
     }
    },
    "domain": {
     "type": "string"
    }
   }
  },
  "probes": {
   "type": "object",
   "required": [
    "csv",
    "rows",
    "columns"
   ],
   "properties": {
    "csv": {
     "type": "object",
     "required": [
      "url",
      "path",
      "media_type",
      "bytes",
      "sha256"
     ],
     "properties": {
      "url": {
       "type": "string",
       "format": "uri",
       "description": "absolute URL; the ?v= query is the file's SHA-256 prefix, so a changed file has a new URL"
      },
      "path": {
       "type": "string",
       "description": "path below the API base"
      },
      "media_type": {
       "type": "string"
      },
      "bytes": {
       "type": "integer",
       "minimum": 0
      },
      "sha256": {
       "type": "string",
       "pattern": "^[0-9a-f]{64}$"
      }
     }
    },
    "rows": {
     "type": "integer"
    },
    "columns": {
     "type": "array",
     "items": {
      "type": "string"
     }
    },
    "columns_meaning": {
     "type": "string"
    }
   }
  },
  "scoring": {
   "type": "object",
   "required": [
    "U_ref_m_s",
    "U_ref_meaning",
    "value_columns",
    "key_columns",
    "conventions"
   ],
   "properties": {
    "U_ref_m_s": {
     "type": [
      "number",
      "null"
     ],
     "description": "the measured velocities are divided by this (k by its square); null where the table holds ratios"
    },
    "U_ref_meaning": {
     "type": "string"
    },
    "theta": {
     "type": [
      "object",
      "null"
     ]
    },
    "scored_as": {
     "type": "object"
    },
    "value_columns": {
     "type": "array",
     "items": {
      "type": "string"
     }
    },
    "key_columns": {
     "type": "array",
     "items": {
      "type": "string"
     }
    },
    "conventions": {
     "type": "string"
    },
    "metric_meaning": {
     "type": "object"
    },
    "tool": {
     "type": "string"
    }
   }
  },
  "approach_flow": {
   "type": "object",
   "required": [
    "source",
    "units",
    "rows",
    "csv"
   ],
   "properties": {
    "source": {
     "type": "string"
    },
    "units": {
     "type": "object"
    },
    "rows": {
     "type": "array",
     "items": {
      "type": "object",
      "required": [
       "z",
       "U"
      ],
      "properties": {
       "z": {
        "type": "number"
       },
       "U": {
        "type": "number"
       },
       "k": {
        "type": [
         "number",
         "null"
        ]
       },
       "u_rms": {
        "type": [
         "number",
         "null"
        ]
       }
      }
     }
    },
    "csv": {
     "type": "object",
     "required": [
      "url",
      "path",
      "media_type",
      "bytes",
      "sha256"
     ],
     "properties": {
      "url": {
       "type": "string",
       "format": "uri",
       "description": "absolute URL; the ?v= query is the file's SHA-256 prefix, so a changed file has a new URL"
      },
      "path": {
       "type": "string",
       "description": "path below the API base"
      },
      "media_type": {
       "type": "string"
      },
      "bytes": {
       "type": "integer",
       "minimum": 0
      },
      "sha256": {
       "type": "string",
       "pattern": "^[0-9a-f]{64}$"
      }
     }
    }
   }
  },
  "points": {
   "type": "object",
   "required": [
    "url",
    "csv",
    "rows",
    "distinct_points",
    "columns"
   ],
   "properties": {
    "url": {
     "type": "string",
     "format": "uri"
    },
    "csv": {
     "type": "object",
     "required": [
      "url",
      "path",
      "media_type",
      "bytes",
      "sha256"
     ],
     "properties": {
      "url": {
       "type": "string",
       "format": "uri",
       "description": "absolute URL; the ?v= query is the file's SHA-256 prefix, so a changed file has a new URL"
      },
      "path": {
       "type": "string",
       "description": "path below the API base"
      },
      "media_type": {
       "type": "string"
      },
      "bytes": {
       "type": "integer",
       "minimum": 0
      },
      "sha256": {
       "type": "string",
       "pattern": "^[0-9a-f]{64}$"
      }
     }
    },
    "rows": {
     "type": "integer"
    },
    "distinct_points": {
     "type": "integer"
    },
    "columns": {
     "type": "array",
     "items": {
      "type": "string"
     }
    }
   }
  },
  "geometry": {
   "type": "object",
   "required": [
    "url",
    "files"
   ],
   "properties": {
    "url": {
     "type": "string",
     "format": "uri"
    },
    "files": {
     "type": "array",
     "items": {
      "type": "object",
      "required": [
       "configuration",
       "url",
       "triangles",
       "watertight"
      ],
      "properties": {
       "configuration": {
        "type": "string"
       },
       "url": {
        "type": "string",
        "format": "uri"
       },
       "triangles": {
        "type": "integer"
       },
       "watertight": {
        "type": "boolean"
       }
      }
     }
    }
   }
  },
  "validation": {
   "type": "object",
   "required": [
    "url",
    "status",
    "engines"
   ],
   "properties": {
    "url": {
     "type": "string",
     "format": "uri"
    },
    "status": {
     "enum": [
      "scored",
      "pending"
     ]
    },
    "engines": {
     "type": "object",
     "additionalProperties": {
      "enum": [
       "scored",
       "running",
       "pending",
       "not comparable"
      ]
     }
    }
   }
  },
  "known_issues": {
   "type": "array",
   "items": {
    "type": "string"
   },
   "minItems": 1
  },
  "people": {
   "type": "object",
   "required": [
    "data_collectors",
    "editors_distributors"
   ],
   "properties": {
    "data_collectors": {
     "type": "array",
     "items": {
      "type": "string"
     }
    },
    "editors_distributors": {
     "type": "array",
     "items": {
      "type": "string"
     }
    }
   }
  },
  "doi": {
   "type": [
    "string",
    "null"
   ]
  },
  "citation_requested": {
   "type": "string"
  },
  "render": {
   "type": "string",
   "format": "uri"
  },
  "page": {
   "type": "string",
   "format": "uri"
  },
  "citation": {
   "type": "object",
   "required": [
    "apa",
    "bibtex"
   ],
   "properties": {
    "apa": {
     "type": "string"
    },
    "bibtex": {
     "type": "string"
    }
   }
  }
 }
}
