{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://hotosm.github.io/fAIr-models/schemas/v1.0.0/dataset/schema.json",
  "title": "fAIr Dataset Extension",
  "description": "STAC extension for fAIr dataset items. Extends Label Extension with fAIr-specific training data metadata.",
  "oneOf": [
    {
      "allOf": [
        {
          "$ref": "#/definitions/stac_extensions"
        },
        {
          "type": "object",
          "required": [
            "type",
            "properties",
            "assets"
          ],
          "properties": {
            "type": {
              "const": "Feature"
            },
            "properties": {
              "allOf": [
                {
                  "required": [
                    "title",
                    "description",
                    "label:type",
                    "label:tasks",
                    "label:classes",
                    "keywords",
                    "fair:user_id",
                    "version",
                    "deprecated"
                  ]
                },
                {
                  "$ref": "#/definitions/fields"
                }
              ]
            },
            "assets": {
              "type": "object",
              "required": [
                "chips",
                "labels"
              ],
              "properties": {
                "chips": {
                  "type": "object",
                  "required": [
                    "href"
                  ],
                  "properties": {
                    "href": {
                      "type": "string",
                      "minLength": 1
                    }
                  }
                },
                "labels": {
                  "type": "object",
                  "required": [
                    "href"
                  ],
                  "properties": {
                    "href": {
                      "type": "string",
                      "minLength": 1
                    }
                  }
                },
                "download": {
                  "type": "object",
                  "required": [
                    "href"
                  ],
                  "properties": {
                    "href": {
                      "type": "string",
                      "minLength": 1
                    }
                  }
                },
                "thumbnail": {
                  "type": "object",
                  "required": [
                    "href"
                  ],
                  "properties": {
                    "href": {
                      "type": "string",
                      "minLength": 1
                    }
                  }
                }
              }
            }
          }
        }
      ]
    }
  ],
  "definitions": {
    "stac_extensions": {
      "type": "object",
      "required": [
        "stac_extensions"
      ],
      "properties": {
        "stac_extensions": {
          "type": "array",
          "contains": {
            "const": "https://hotosm.github.io/fAIr-models/schemas/v1.0.0/dataset/schema.json"
          }
        }
      }
    },
    "fields": {
      "type": "object",
      "properties": {
        "fair:user_id": {
          "type": "string",
          "minLength": 1
        },
        "fair:chip_count": {
          "type": "integer",
          "minimum": 1
        },
        "fair:source_imagery": {
          "type": "string"
        },
        "label:type": {
          "type": "string",
          "enum": [
            "vector",
            "raster"
          ]
        },
        "label:tasks": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "label:classes": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "name",
              "classes"
            ],
            "properties": {
              "name": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "classes": {
                "type": "array",
                "items": {
                  "type": [
                    "string",
                    "number"
                  ]
                }
              }
            }
          }
        },
        "label:description": {
          "type": "string"
        },
        "label:methods": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "keywords": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "version": {
          "type": "string",
          "minLength": 1
        },
        "deprecated": {
          "type": "boolean"
        },
        "license": {
          "type": "string"
        },
        "providers": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "name",
              "roles"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "roles": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "url": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      },
      "patternProperties": {
        "^(?!fair:)": {}
      }
    }
  }
}