{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://adminoptionspages.com/schema/export.v1.json",
  "title": "Admin Options Pages export, version 1",
  "description": "The file that Import/Export downloads. Fields of a page are only checked here for what every field has; their settings are sanitized by their field type on import.",
  "type": "object",
  "required": ["aop_export_version", "menus_and_pages"],
  "properties": {
    "aop_export_version": { "const": 1 },
    "plugin_version": { "type": "string", "maxLength": 32 },
    "generated": { "type": "string", "maxLength": 40 },
    "menus_and_pages": {
      "type": "array",
      "maxItems": 200,
      "items": {
        "type": "object",
        "required": ["menu_slug", "page_value"],
        "properties": {
          "menu_slug": { "type": "string", "minLength": 1, "maxLength": 191 },
          "page_value": { "$ref": "#/$defs/pageValue" }
        }
      }
    },
    "options": {
      "type": "object",
      "maxProperties": 5000,
      "description": "Option name to value, for the options of the fields of the menus in this file."
    }
  },
  "$defs": {
    "pageValue": {
      "type": "object",
      "required": ["menu_id", "pages"],
      "anyOf": [{ "required": ["menu"] }, { "required": ["existing_menu"] }],
      "properties": {
        "menu_id": { "type": ["string", "integer"], "maxLength": 40 },
        "side_bar_visible": { "type": "boolean" },
        "menu": {
          "type": "object",
          "required": ["menu_title", "menu_slug"],
          "properties": {
            "page_title": { "type": "string", "maxLength": 191 },
            "menu_title": { "type": "string", "maxLength": 191 },
            "capability": { "type": "string", "maxLength": 64 },
            "menu_slug": { "type": "string", "maxLength": 191 },
            "menu_slug_suffix": { "type": "string", "maxLength": 191 },
            "icon_url": { "type": "string", "maxLength": 191 },
            "position": { "type": ["string", "integer", "number"], "maxLength": 12 }
          }
        },
        "existing_menu": {
          "type": "object",
          "required": ["menu_slug"],
          "properties": {
            "menu_name": { "type": "string", "maxLength": 191 },
            "menu_slug": { "type": "string", "maxLength": 191 }
          }
        },
        "pages": {
          "type": "array",
          "minItems": 1,
          "maxItems": 100,
          "items": {
            "type": "object",
            "required": ["menu_title", "menu_slug", "fields"],
            "properties": {
              "parent_slug": { "type": "string", "maxLength": 191 },
              "page_title": { "type": "string", "maxLength": 191 },
              "subpage_title": { "type": "string", "maxLength": 191 },
              "menu_title": { "type": "string", "maxLength": 191 },
              "capability": { "type": "string", "maxLength": 64 },
              "roles": {
                "type": "array",
                "maxItems": 50,
                "items": { "type": "string", "maxLength": 64, "pattern": "^[a-z0-9_-]+$" }
              },
              "menu_slug": { "type": "string", "maxLength": 191 },
              "subpage_slug_suffix": { "type": "string", "maxLength": 191 },
              "include_tab": { "type": "boolean" },
              "select_title": { "type": "string", "maxLength": 191 },
              "subpage_toggle": { "type": "boolean" },
              "fields": {
                "type": "array",
                "maxItems": 500,
                "items": {
                  "type": "object",
                  "required": ["type"],
                  "properties": {
                    "id": { "type": ["string", "integer"], "maxLength": 40 },
                    "type": { "type": "string", "minLength": 1, "maxLength": 64 },
                    "field_name": { "type": "string", "maxLength": 191 },
                    "field_label": { "type": "string", "maxLength": 1000 }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
