{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://stac-extensions.github.io/file/v2.1.0/schema.json#",
  "title": "File Info Extension",
  "description": "STAC File Info Extension for STAC Items, STAC Catalogs, and STAC Collections.",
  "oneOf": [
    {
      "$comment": "This is the schema for STAC Items.",
      "allOf": [
        {
          "type": "object",
          "required": [
            "type",
            "assets"
          ],
          "properties": {
            "type": {
              "const": "Feature"
            },
            "assets": {
              "type": "object",
              "additionalProperties": {
                "$ref": "#/definitions/fields"
              }
            },
            "links": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/fields"
              }
            }
          }
        },
        {
          "$ref": "#/definitions/stac_extensions"
        }
      ]
    },
    {
      "$comment": "This is the schema for STAC Catalogs.",
      "allOf": [
        {
          "type": "object",
          "required": [
            "type"
          ],
          "properties": {
            "type": {
              "const": "Catalog"
            },
            "links": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/fields"
              }
            }
          }
        },
        {
          "$ref": "#/definitions/stac_extensions"
        }
      ]
    },
    {
      "$comment": "This is the schema for STAC Collections.",
      "allOf": [
        {
          "type": "object",
          "required": [
            "type"
          ],
          "properties": {
            "type": {
              "const": "Collection"
            },
            "assets": {
              "type": "object",
              "additionalProperties": {
                "$ref": "#/definitions/fields"
              }
            },
            "links": {
              "type": "array",
              "items": {
                "$ref": "#/definitions/fields"
              }
            },
            "item_assets": {
              "type": "object",
              "additionalProperties": {
                "$ref": "#/definitions/fields"
              }
            }
          }
        },
        {
          "$ref": "#/definitions/stac_extensions"
        }
      ]
    }
  ],
  "definitions": {
    "stac_extensions": {
      "type": "object",
      "required": [
        "stac_extensions"
      ],
      "properties": {
        "stac_extensions": {
          "type": "array",
          "contains": {
            "const": "https://stac-extensions.github.io/file/v2.1.0/schema.json"
          }
        }
      }
    },
    "fields": {
      "$comment": "Add your new fields here. Don't require them here, do that above in the item schema.",
      "type": "object",
      "properties": {
        "file:byte_order": {
          "type": "string",
          "enum": [
            "big-endian",
            "little-endian"
          ],
          "title": "File Byte Order"
        },
        "file:checksum": {
          "type": "string",
          "pattern": "^[a-f0-9]+$",
          "title": "File Checksum (Multihash)"
        },
        "file:header_size": {
          "type": "integer",
          "minimum": 0,
          "title": "File Header Size"
        },
        "file:size": {
          "type": "integer",
          "minimum": 0,
          "title": "File Size"
        },
        "file:values": {
          "type": "array",
          "minItems": 1,
          "items": {
            "type": "object",
            "required": [
              "values",
              "summary"
            ],
            "properties": {
              "values": {
                "type": "array",
                "minItems": 1,
                "items": {
                  "description": "Any data type is allowed"
                }
              },
              "summary": {
                "type": "string",
                "minLength": 1
              }
            }
          }
        },
        "file:local_path": {
          "type": "string",
          "pattern": "^[^\\r\\n\\t\\\\:'\"/]+(/[^\\r\\n\\t\\\\:'\"/]+)*/?$",
          "title": "Relative File Path"
        }
      },
      "patternProperties": {
        "^(?!file:)": {
          "$comment": "Above, change `template` to the prefix of this extension"
        }
      },
      "additionalProperties": false
    }
  }
}
