{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "STAC Collection Specification",
  "description": "This object represents Collections in a SpatioTemporal Asset Catalog (adapted from official specs)",
  "allOf": [
    {
      "$ref": "#/definitions/collection"
    },
    {
      "$ref": "https://raw.githubusercontent.com/radiantearth/stac-spec/master/item-spec/json-schema/common.json"
    },
    {
      "$ref": "https://ogcincubator.github.io/bblocks-stac/build/annotated/contrib/stac/components/assets/schema.json"
    }
  ],
  "definitions": {
    "collection": {
      "title": "STAC Collection",
      "description": "These are the fields specific to a STAC Collection.",
      "type": "object",
      "$comment": "title, description, keywords, providers and license is validated through the common metadata.",
      "required": [
        "type",
        "id",
        "description",
        "license",
        "extent",
        "links"
      ],
      "properties": {
        "stac_extensions": {
          "title": "STAC extensions",
          "type": "array",
          "uniqueItems": true,
          "items": {
            "title": "Reference to a JSON Schema",
            "type": "string",
            "format": "iri"
          },
          "x-jsonld-id": "https://w3id.org/ogc/stac/core/hasExtension"
        },
        "type": {
          "title": "Type of STAC entity",
          "const": "Collection",
          "x-jsonld-id": "@type"
        },
        "id": {
          "title": "Identifier",
          "type": "string",
          "minLength": 1,
          "x-jsonld-id": "@id"
        },
        "extent": {
          "title": "Extents",
          "type": "object",
          "required": [
            "spatial",
            "temporal"
          ],
          "properties": {
            "spatial": {
              "title": "Spatial extent object",
              "type": "object",
              "required": [
                "bbox"
              ],
              "properties": {
                "bbox": {
                  "title": "Spatial extents",
                  "type": "array",
                  "oneOf": [
                    {
                      "minItems": 1,
                      "maxItems": 1
                    },
                    {
                      "minItems": 3
                    }
                  ],
                  "items": {
                    "title": "Spatial extent",
                    "type": "array",
                    "oneOf": [
                      {
                        "minItems": 4,
                        "maxItems": 4
                      },
                      {
                        "minItems": 6,
                        "maxItems": 6
                      }
                    ],
                    "items": {
                      "type": "number"
                    }
                  }
                }
              }
            },
            "temporal": {
              "title": "Temporal extent object",
              "type": "object",
              "required": [
                "interval"
              ],
              "properties": {
                "interval": {
                  "title": "Temporal extents",
                  "type": "array",
                  "minItems": 1,
                  "items": {
                    "title": "Temporal extent",
                    "type": "array",
                    "minItems": 2,
                    "maxItems": 2,
                    "items": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "format": "date-time",
                      "pattern": "(\\+00:00|Z)$"
                    }
                  }
                }
              }
            }
          },
          "x-jsonld-id": "http://purl.org/dc/terms/extent"
        },
        "item_assets": {
          "additionalProperties": {
            "allOf": [
              {
                "type": "object",
                "minProperties": 2,
                "properties": {
                  "href": {
                    "title": "Disallow href",
                    "not": {}
                  },
                  "title": {
                    "title": "Asset title",
                    "type": "string",
                    "x-jsonld-id": "http://purl.org/dc/terms/title"
                  },
                  "description": {
                    "title": "Asset description",
                    "type": "string",
                    "x-jsonld-id": "http://purl.org/dc/terms/description"
                  },
                  "type": {
                    "title": "Asset type",
                    "type": "string",
                    "x-jsonld-id": "@type"
                  },
                  "roles": {
                    "title": "Asset roles",
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              {
                "$ref": "https://raw.githubusercontent.com/radiantearth/stac-spec/master/item-spec/json-schema/common.json"
              }
            ]
          }
        },
        "links": {
          "type": "array",
          "items": {
            "$ref": "https://opengeospatial.github.io/bblocks/annotated-schemas/ogc-utils/json-link/schema.json"
          },
          "x-jsonld-id": "http://www.w3.org/2000/01/rdf-schema#seeAlso"
        },
        "summaries": {
          "$ref": "#/definitions/summaries"
        }
      }
    },
    "summaries": {
      "type": "object",
      "additionalProperties": {
        "anyOf": [
          {
            "title": "JSON Schema",
            "type": "object",
            "minProperties": 1,
            "allOf": [
              {
                "$ref": "http://json-schema.org/draft-07/schema"
              }
            ]
          },
          {
            "title": "Range",
            "type": "object",
            "required": [
              "minimum",
              "maximum"
            ],
            "properties": {
              "minimum": {
                "title": "Minimum value",
                "type": [
                  "number",
                  "string"
                ]
              },
              "maximum": {
                "title": "Maximum value",
                "type": [
                  "number",
                  "string"
                ]
              }
            }
          },
          {
            "title": "Set of values",
            "type": "array",
            "minItems": 1,
            "items": {
              "description": "For each field only the original data type of the property can occur (except for arrays), but we can't validate that in JSON Schema yet. See the sumamry description in the STAC specification for details."
            }
          }
        ]
      }
    }
  },
  "x-jsonld-extra-terms": {
    "stac_version": "https://w3id.org/ogc/stac/core/version",
    "keywords": "http://purl.org/dc/terms/subject",
    "license": "http://purl.org/dc/terms/license",
    "datetime": {
      "x-jsonld-id": "http://purl.org/dc/terms/date",
      "x-jsonld-type": "xsd:dateTime"
    },
    "start_datetime": {
      "x-jsonld-id": "https://w3id.org/ogc/stac/core/start_datetime",
      "x-jsonld-type": "xsd:dateTime"
    },
    "end_datetime": {
      "x-jsonld-id": "https://w3id.org/ogc/stac/core/end_datetime",
      "x-jsonld-type": "xsd:dateTime"
    },
    "providers": "https://w3id.org/ogc/stac/core/hasProvider",
    "media_type": "http://purl.org/dc/terms/format"
  },
  "x-jsonld-prefixes": {
    "stac": "https://w3id.org/ogc/stac/core/",
    "dct": "http://purl.org/dc/terms/",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#"
  }
}