{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://stac.linz.govt.nz/v0.0.15/film/schema.json",
  "title": "Film Extension",
  "description": "STAC Film Extension for STAC Items, and Collection Summaries.",
  "allOf": [
    {
      "$ref": "#/definitions/stac_extensions"
    },
    {
      "if": {
        "type": "object",
        "properties": {
          "type": {
            "const": "Feature"
          }
        }
      },
      "then": {
        "$comment": "This is the schema for STAC Items.",
        "allOf": [
          {
            "type": "object",
            "required": ["type", "properties", "assets"],
            "properties": {
              "properties": {
                "allOf": [
                  {
                    "type": "object",
                    "required": ["film:id", "film:negative_sequence"]
                  },
                  {
                    "$ref": "#/definitions/fields"
                  }
                ]
              },
              "assets": {
                "type": "object",
                "additionalProperties": {
                  "$ref": "#/definitions/fields"
                }
              }
            }
          }
        ]
      },
      "else": {
        "if": {
          "type": "object",
          "properties": {
            "type": {
              "const": "Collection"
            }
          }
        },
        "then": {
          "$comment": "This is the schema for STAC Collections. This extension requires this for Collection summaries.",
          "type": "object",
          "allOf": [
            {
              "required": ["type"]
            },
            {
              "$ref": "#/definitions/fields"
            }
          ]
        },
        "else": false
      }
    }
  ],
  "definitions": {
    "stac_extensions": {
      "type": "object",
      "required": ["stac_extensions"],
      "properties": {
        "stac_extensions": {
          "type": "array",
          "contains": {
            "const": "https://stac.linz.govt.nz/v0.0.15/film/schema.json"
          }
        }
      }
    },
    "fields": {
      "type": "object",
      "properties": {
        "film:id": {
          "title": "Film ID",
          "type": "string"
        },
        "film:negative_sequence": {
          "title": "Negative Sequence Number",
          "type": "integer"
        },
        "film:physical_condition": {
          "title": "Physical Film Condition",
          "type": "string"
        },
        "film:physical_size": {
          "title": "Physical Size Format",
          "type": "string"
        },
        "summaries": {
          "type": "object",
          "required": ["film:id", "film:negative_sequence"],
          "properties": {
            "film:id": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "minItems": 1
            },
            "film:negative_sequence": {
              "type": "object",
              "required": ["minimum", "maximum"],
              "properties": {
                "minimum": {
                  "title": "Lowest negative sequence number",
                  "type": "integer"
                },
                "maximum": {
                  "title": "Highest negative sequence number",
                  "type": "integer"
                }
              }
            },
            "film:physical_condition": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "minItems": 1
            },
            "film:physical_size": {
              "type": "array",
              "items": {
                "type": "string"
              },
              "minItems": 1
            }
          }
        }
      },
      "patternProperties": {
        "^(?!film:)": {}
      },
      "additionalProperties": false
    }
  }
}
