{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://json.schemastore.org/bigquery-table",
  "definitions": {
    "field_name": {
      "type": "string"
    },
    "field_type": {
      "type": "string",
      "enum": [
        "INT64",
        "INTEGER",
        "FLOAT64",
        "FLOAT",
        "NUMERIC",
        "BIGNUMERIC",
        "BOOL",
        "BOOLEAN",
        "STRING",
        "BYTES",
        "DATE",
        "DATETIME",
        "TIME",
        "TIMESTAMP",
        "STRUCT",
        "RECORD",
        "JSON",
        "GEOGRAPHY"
      ]
    },
    "field_mode": {
      "type": "string",
      "enum": ["NULLABLE", "REQUIRED", "REPEATED"]
    },
    "field_description": {
      "type": "string"
    },
    "field": {
      "type": "object",
      "required": ["name", "type"],
      "properties": {
        "name": {
          "$ref": "#/definitions/field_name"
        },
        "type": {
          "$ref": "#/definitions/field_type"
        },
        "mode": {
          "$ref": "#/definitions/field_mode"
        },
        "description": {
          "$ref": "#/definitions/field_description"
        }
      },
      "if": {
        "properties": {
          "type": {
            "enum": ["STRUCT", "RECORD"]
          }
        }
      },
      "then": {
        "required": ["fields", "type", "name"],
        "properties": {
          "name": {
            "$ref": "#/definitions/field_name"
          },
          "type": {
            "$ref": "#/definitions/field_type"
          },
          "mode": {
            "$ref": "#/definitions/field_mode"
          },
          "description": {
            "$ref": "#/definitions/field_description"
          },
          "fields": {
            "type": "array",
            "items": {
              "$ref": "#/definitions/field"
            }
          }
        }
      }
    }
  },
  "description": "BigQuery lets you specify a table's schema when you load data into a table or when you create an empty table. A table schema is a JSON file.",
  "items": {
    "$ref": "#/definitions/field"
  },
  "type": "array"
}
