{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:altium-monkey:schema:design_a2",
  "title": "Altium Monkey design a2",
  "description": "Full Altium design analysis emitted by AltiumDesign.to_json().",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "schema",
    "generator",
    "project",
    "variants",
    "options",
    "sheets",
    "components",
    "schematic_hierarchy",
    "physical_pages",
    "nets"
  ],
  "properties": {
    "schema": {
      "const": "altium_monkey.design.a2"
    },
    "generator": {
      "const": "altium_monkey"
    },
    "project": {
      "$ref": "#/$defs/project"
    },
    "variants": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/variant"
      }
    },
    "options": {
      "$ref": "#/$defs/options"
    },
    "sheets": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/sheet"
      }
    },
    "components": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/design_component"
      }
    },
    "schematic_hierarchy": {
      "$ref": "#/$defs/schematic_hierarchy"
    },
    "pnp": {
      "$ref": "#/$defs/pnp"
    },
    "compile": {
      "$ref": "#/$defs/compile"
    },
    "diagnostics": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/diagnostic"
      }
    },
    "physical_pages": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/physical_page"
      }
    },
    "nets": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/design_net"
      }
    },
    "indexes": {
      "$ref": "#/$defs/indexes"
    }
  },
  "$defs": {
    "string_or_null": {
      "type": [
        "string",
        "null"
      ]
    },
    "integer_or_null": {
      "type": [
        "integer",
        "null"
      ]
    },
    "string_list": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "string_list_map": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/$defs/string_list"
      }
    },
    "sheet": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "filename",
        "sheet_number"
      ],
      "properties": {
        "filename": {
          "type": "string"
        },
        "sheet_number": {
          "type": [
            "integer",
            "string"
          ],
          "description": "Canonical decimal sheet numbers are emitted as integers for compatibility; non-canonical Altium SheetNumber parameter values are emitted as exact strings."
        }
      }
    },
    "parameter_map": {
      "type": "object",
      "additionalProperties": true
    },
    "variant_key_values": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    },
    "variant": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "dnp"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "dnp": {
          "$ref": "#/$defs/string_list"
        },
        "variations": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/variant_key_values"
          }
        },
        "parameters": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/variant_key_values"
          }
        },
        "param_variations": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/variant_key_values"
          }
        },
        "parameter_overrides": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/parameter_map"
          }
        },
        "is_current": {
          "type": "boolean"
        }
      }
    },
    "project": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "name",
        "filename",
        "parameters"
      ],
      "properties": {
        "name": {
          "$ref": "#/$defs/string_or_null"
        },
        "filename": {
          "$ref": "#/$defs/string_or_null"
        },
        "parameters": {
          "$ref": "#/$defs/parameter_map"
        },
        "current_variant": {
          "$ref": "#/$defs/string_or_null"
        }
      }
    },
    "design_component": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "designator"
      ],
      "properties": {
        "designator": {
          "type": "string"
        },
        "svg_id": {
          "$ref": "#/$defs/string_or_null"
        },
        "value": {
          "type": "string"
        },
        "footprint": {
          "type": "string"
        },
        "library_ref": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "hierarchy": {
          "$ref": "#/$defs/freeform_object"
        },
        "classification": {
          "$ref": "#/$defs/freeform_object"
        },
        "parameters": {
          "$ref": "#/$defs/parameter_map"
        },
        "compiled_component_id": {
          "type": "string"
        },
        "physical_document_id": {
          "type": "string"
        },
        "physical_page_id": {
          "type": "string"
        },
        "source_unique_id": {
          "$ref": "#/$defs/string_or_null"
        },
        "source_unique_id_path": {
          "$ref": "#/$defs/string_or_null"
        },
        "dnp": {
          "type": "boolean"
        },
        "fitted": {
          "type": "boolean"
        },
        "ambiguous_physical_designator": {
          "type": "boolean"
        }
      }
    },
    "pnp": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "units",
        "position_mode",
        "source_pcbdoc",
        "placements"
      ],
      "properties": {
        "units": {
          "const": "mm"
        },
        "position_mode": {
          "enum": [
            "altium-pick-place",
            "component-origin"
          ]
        },
        "source_pcbdoc": {
          "type": "string"
        },
        "placements": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/pnp_placement"
          }
        }
      }
    },
    "compile": {
      "type": "object",
      "additionalProperties": true,
      "properties": {
        "schema": {
          "type": "string"
        },
        "summary": {
          "$ref": "#/$defs/freeform_object"
        },
        "options": {
          "$ref": "#/$defs/freeform_object"
        },
        "annotation": {
          "$ref": "#/$defs/freeform_object"
        },
        "stats": {
          "$ref": "#/$defs/freeform_object"
        }
      }
    },
    "diagnostic": {
      "type": "object",
      "additionalProperties": true
    },
    "physical_page": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "id",
        "components",
        "nets"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "logical_document_id": {
          "type": "string"
        },
        "physical_instance_path": {
          "type": "string"
        },
        "physical_instance_unique_id": {
          "type": "string"
        },
        "compiled_sheet_index": {
          "type": "integer"
        },
        "components": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/physical_page_component"
          }
        },
        "nets": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/physical_page_net"
          }
        }
      }
    },
    "physical_page_component": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "designator"
      ],
      "properties": {
        "designator": {
          "type": "string"
        },
        "svg_id": {
          "$ref": "#/$defs/string_or_null"
        }
      }
    },
    "physical_page_net": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "name"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "aliases": {
          "$ref": "#/$defs/string_list"
        },
        "name_sources": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/name_source"
          }
        },
        "graphical": {
          "$ref": "#/$defs/freeform_object"
        }
      }
    },
    "design_net": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "uid",
        "name",
        "auto_named",
        "source_sheets",
        "terminals",
        "graphical",
        "aliases"
      ],
      "properties": {
        "uid": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "auto_named": {
          "type": "boolean"
        },
        "source_sheets": {
          "$ref": "#/$defs/string_list"
        },
        "terminals": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/terminal"
          }
        },
        "graphical": {
          "$ref": "#/$defs/freeform_object"
        },
        "aliases": {
          "$ref": "#/$defs/string_list"
        },
        "endpoints": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/endpoint"
          }
        },
        "hierarchy_paths": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/net_hierarchy_path"
          }
        },
        "name_sources": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/name_source"
          }
        }
      }
    },
    "name_source": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "name",
        "role",
        "source"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "role": {
          "type": "string"
        },
        "source": {
          "type": "string"
        }
      }
    },
    "indexes": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "svg_to_component": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "svg_to_components": {
          "$ref": "#/$defs/string_list_map"
        },
        "physical_svg_to_components": {
          "$ref": "#/$defs/string_list_map"
        },
        "component_to_physical_page": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "physical_page_to_components": {
          "$ref": "#/$defs/string_list_map"
        },
        "physical_page_to_nets": {
          "$ref": "#/$defs/string_list_map"
        },
        "net_to_physical_pages": {
          "$ref": "#/$defs/string_list_map"
        },
        "component_to_nets": {
          "$ref": "#/$defs/string_list_map"
        },
        "net_to_components": {
          "$ref": "#/$defs/string_list_map"
        }
      }
    },
    "schematic_hierarchy": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "schema",
        "requested_scope",
        "effective_scope",
        "documents",
        "sheet_symbols",
        "hierarchy_paths",
        "channels",
        "links",
        "unresolved"
      ],
      "properties": {
        "schema": {
          "const": "altium_monkey.schematic_hierarchy.a1"
        },
        "requested_scope": {
          "type": "string"
        },
        "effective_scope": {
          "type": "string"
        },
        "documents": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/hierarchy_document"
          }
        },
        "sheet_symbols": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/hierarchy_sheet_symbol"
          }
        },
        "hierarchy_paths": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/hierarchy_path_record"
          }
        },
        "channels": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/hierarchy_channel"
          }
        },
        "links": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/hierarchy_link"
          }
        },
        "harness_bundle_links": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/harness_bundle_link"
          }
        },
        "unresolved": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/freeform_object"
          }
        }
      }
    },
    "hierarchy_document": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "sheet_index",
        "filename",
        "path",
        "is_top_level",
        "metadata"
      ],
      "properties": {
        "sheet_index": {
          "type": "integer"
        },
        "filename": {
          "type": "string"
        },
        "path": {
          "type": "string"
        },
        "is_top_level": {
          "type": "boolean"
        },
        "metadata": {
          "$ref": "#/$defs/freeform_object"
        }
      }
    },
    "hierarchy_sheet_symbol": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "id",
        "parent_sheet_index",
        "designator",
        "child_filename",
        "child_sheet_indices",
        "entries",
        "metadata"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "parent_sheet_index": {
          "type": "integer"
        },
        "designator": {
          "type": "string"
        },
        "child_filename": {
          "type": "string"
        },
        "child_sheet_indices": {
          "type": "array",
          "items": {
            "type": "integer"
          }
        },
        "repeat": {
          "$ref": "#/$defs/freeform_object"
        },
        "entries": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/freeform_object"
          }
        },
        "metadata": {
          "$ref": "#/$defs/freeform_object"
        }
      }
    },
    "hierarchy_path_record": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "id",
        "levels"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "source_sheet_index": {
          "type": [
            "integer",
            "null"
          ]
        },
        "compiled_sheet_index": {
          "type": [
            "integer",
            "null"
          ]
        },
        "levels": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/hierarchy_level"
          }
        }
      }
    },
    "hierarchy_channel": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "id",
        "sheet_symbol_id",
        "parent_sheet_index",
        "child_sheet_index",
        "instance_index",
        "hierarchy_path_id"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "sheet_symbol_id": {
          "type": "string"
        },
        "parent_sheet_index": {
          "type": "integer"
        },
        "child_sheet_index": {
          "type": "integer"
        },
        "compiled_child_sheet_index": {
          "type": [
            "integer",
            "null"
          ]
        },
        "instance_index": {
          "type": "integer"
        },
        "channel_name": {
          "type": "string"
        },
        "hierarchy_path_id": {
          "type": "string"
        }
      }
    },
    "hierarchy_link": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "id",
        "kind",
        "parent",
        "child",
        "match_kind",
        "hierarchy_path_id",
        "metadata"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "kind": {
          "type": "string"
        },
        "parent": {
          "$ref": "#/$defs/freeform_object"
        },
        "child": {
          "$ref": "#/$defs/freeform_object"
        },
        "match_kind": {
          "type": "string"
        },
        "hierarchy_path_id": {
          "type": "string"
        },
        "metadata": {
          "$ref": "#/$defs/freeform_object"
        }
      }
    },
    "harness_bundle_link": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "id",
        "kind",
        "topology",
        "name",
        "parent",
        "child",
        "bundle",
        "match_kind",
        "metadata"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "kind": {
          "const": "harness_bundle"
        },
        "topology": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "parent": {
          "$ref": "#/$defs/freeform_object"
        },
        "child": {
          "$ref": "#/$defs/freeform_object"
        },
        "bundle": {
          "$ref": "#/$defs/freeform_object"
        },
        "match_kind": {
          "type": "string"
        },
        "metadata": {
          "$ref": "#/$defs/freeform_object"
        }
      }
    },
    "options": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "net_identifier_scope",
        "allow_ports_to_name_nets",
        "allow_sheet_entries_to_name_nets",
        "allow_single_pin_nets",
        "append_sheet_numbers_to_local_nets",
        "power_port_names_take_priority",
        "higher_level_names_take_priority",
        "auto_sheet_numbering"
      ],
      "properties": {
        "net_identifier_scope": {
          "type": "string"
        },
        "allow_ports_to_name_nets": {
          "type": "boolean"
        },
        "allow_sheet_entries_to_name_nets": {
          "type": "boolean"
        },
        "allow_single_pin_nets": {
          "type": "boolean"
        },
        "append_sheet_numbers_to_local_nets": {
          "type": "boolean"
        },
        "power_port_names_take_priority": {
          "type": "boolean"
        },
        "higher_level_names_take_priority": {
          "type": "boolean"
        },
        "auto_sheet_numbering": {
          "type": "boolean"
        }
      }
    },
    "pnp_placement": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "designator"
      ],
      "properties": {
        "designator": {
          "type": "string"
        }
      }
    },
    "terminal": {
      "type": "object",
      "additionalProperties": true,
      "required": [
        "designator",
        "pin"
      ],
      "properties": {
        "designator": {
          "type": "string"
        },
        "pin": {
          "type": "string"
        },
        "pin_name": {
          "type": "string"
        },
        "pin_type": {
          "type": "string"
        }
      }
    },
    "endpoint": {
      "type": "object",
      "additionalProperties": true
    },
    "net_hierarchy_path": {
      "type": "object",
      "additionalProperties": true
    },
    "hierarchy_level": {
      "type": "object",
      "additionalProperties": true
    },
    "freeform_object": {
      "type": "object",
      "additionalProperties": true
    }
  }
}
