{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:search-methods:method:v1",
  "title": "method",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "method_id": {
      "type": "string",
      "format": "uuid"
    },
    "schema_version": {
      "const": "1.0"
    },
    "record_version": {
      "type": "integer",
      "minimum": 1
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "pattern": "\\S"
    },
    "slug": {
      "type": "string",
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
    },
    "summary": {
      "type": "string",
      "minLength": 1,
      "pattern": "\\S"
    },
    "topic_ids": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "pattern": "\\S"
      },
      "minItems": 1,
      "uniqueItems": true
    },
    "status": {
      "enum": [
        "active",
        "disputed",
        "outdated",
        "withdrawn"
      ]
    },
    "claims": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/claim"
      },
      "minItems": 1,
      "uniqueItems": false
    },
    "platform_scope": {
      "$ref": "#/$defs/scope"
    },
    "applicability": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "conditions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/condition"
          },
          "minItems": 0,
          "uniqueItems": false
        },
        "unknowns": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "minItems": 0,
          "uniqueItems": true
        },
        "site_types": {
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "pattern": "\\S"
              },
              "minItems": 0,
              "uniqueItems": true
            },
            {
              "type": "null"
            }
          ]
        },
        "page_types": {
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "pattern": "\\S"
              },
              "minItems": 0,
              "uniqueItems": true
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "conditions",
        "unknowns",
        "site_types",
        "page_types"
      ]
    },
    "prerequisites": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "minItems": 0,
          "uniqueItems": true
        },
        {
          "type": "null"
        }
      ]
    },
    "limitations": {
      "anyOf": [
        {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "minItems": 0,
          "uniqueItems": true
        },
        {
          "type": "null"
        }
      ]
    },
    "conflicts": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "entity_id": {
            "type": "string",
            "format": "uuid"
          },
          "record_version": {
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "entity_id",
          "record_version"
        ]
      },
      "minItems": 0,
      "uniqueItems": false
    },
    "related_method_ids": {
      "type": "array",
      "items": {
        "type": "string",
        "format": "uuid"
      },
      "minItems": 0,
      "uniqueItems": true
    },
    "evidence_assessment": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "category": {
          "enum": [
            "official_scope",
            "reproducible_study",
            "case_with_limits",
            "unverified",
            "conflicting"
          ]
        },
        "explanation": {
          "type": "string",
          "minLength": 1,
          "pattern": "\\S"
        }
      },
      "required": [
        "category",
        "explanation"
      ]
    },
    "last_verified_at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time",
          "pattern": "Z$|[+]00:00$"
        },
        {
          "type": "null"
        }
      ]
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "pattern": "Z$|[+]00:00$"
    },
    "instructions": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "text": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "basis_refs": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "entity_id": {
                  "type": "string",
                  "format": "uuid"
                },
                "record_version": {
                  "type": "integer",
                  "minimum": 1
                }
              },
              "required": [
                "entity_id",
                "record_version"
              ]
            },
            "minItems": 1,
            "uniqueItems": false
          }
        },
        "required": [
          "text",
          "basis_refs"
        ]
      },
      "minItems": 0,
      "uniqueItems": false
    }
  },
  "required": [
    "method_id",
    "schema_version",
    "record_version",
    "title",
    "slug",
    "summary",
    "topic_ids",
    "status",
    "claims",
    "platform_scope",
    "applicability",
    "prerequisites",
    "limitations",
    "conflicts",
    "related_method_ids",
    "evidence_assessment",
    "last_verified_at",
    "updated_at"
  ],
  "$defs": {
    "scope": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "mode": {
          "enum": [
            "specified",
            "unrestricted",
            "unknown"
          ]
        },
        "values": {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1,
            "pattern": "\\S"
          },
          "minItems": 0,
          "uniqueItems": true
        }
      },
      "required": [
        "mode",
        "values"
      ],
      "allOf": [
        {
          "if": {
            "properties": {
              "mode": {
                "const": "specified"
              }
            }
          },
          "then": {
            "properties": {
              "values": {
                "minItems": 1
              }
            }
          },
          "else": {
            "properties": {
              "values": {
                "maxItems": 0
              }
            }
          }
        }
      ]
    },
    "condition": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "condition_id": {
          "type": "string",
          "format": "uuid"
        },
        "text": {
          "type": "string",
          "minLength": 1,
          "pattern": "\\S"
        },
        "basis_refs": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "entity_id": {
                "type": "string",
                "format": "uuid"
              },
              "record_version": {
                "type": "integer",
                "minimum": 1
              }
            },
            "required": [
              "entity_id",
              "record_version"
            ]
          },
          "minItems": 1,
          "uniqueItems": false
        }
      },
      "required": [
        "condition_id",
        "text",
        "basis_refs"
      ]
    },
    "evidence": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "evidence_id": {
          "type": "string",
          "format": "uuid"
        },
        "document_revision_id": {
          "type": "string",
          "format": "uuid"
        },
        "source_url": {
          "type": "string",
          "format": "uri",
          "pattern": "^https?://"
        },
        "locator": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "block_id": {
              "type": "string",
              "minLength": 1,
              "pattern": "\\S"
            },
            "start": {
              "type": "integer",
              "minimum": 0
            },
            "end": {
              "type": "integer",
              "minimum": 1
            }
          },
          "required": [
            "block_id",
            "start",
            "end"
          ]
        },
        "excerpt": {
          "type": "string",
          "minLength": 1,
          "pattern": "\\S"
        },
        "original_language": {
          "type": "string",
          "minLength": 1,
          "pattern": "\\S"
        },
        "translated_excerpt": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "pattern": "\\S"
            },
            {
              "type": "null"
            }
          ]
        },
        "translation_language": {
          "anyOf": [
            {
              "type": "string",
              "minLength": 1,
              "pattern": "\\S"
            },
            {
              "type": "null"
            }
          ]
        },
        "independence_group_id": {
          "type": "string",
          "format": "uuid"
        },
        "evidence_type": {
          "enum": [
            "official_document",
            "study",
            "case",
            "opinion"
          ]
        },
        "limitations": {
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "pattern": "\\S"
              },
              "minItems": 0,
              "uniqueItems": true
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "evidence_id",
        "document_revision_id",
        "source_url",
        "locator",
        "excerpt",
        "original_language",
        "translated_excerpt",
        "translation_language",
        "independence_group_id",
        "evidence_type",
        "limitations"
      ]
    },
    "claim": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "claim_id": {
          "type": "string",
          "format": "uuid"
        },
        "record_version": {
          "type": "integer",
          "minimum": 1
        },
        "statement": {
          "type": "string",
          "minLength": 1,
          "pattern": "\\S"
        },
        "claim_type": {
          "enum": [
            "platform_requirement",
            "documented_behavior",
            "experimental_observation",
            "author_recommendation",
            "hypothesis",
            "marketing_claim",
            "definition"
          ]
        },
        "status": {
          "enum": [
            "active",
            "disputed",
            "outdated",
            "withdrawn"
          ]
        },
        "platform_scope": {
          "$ref": "#/$defs/scope"
        },
        "region_scope": {
          "$ref": "#/$defs/scope"
        },
        "language_scope": {
          "$ref": "#/$defs/scope"
        },
        "observed_period": {
          "anyOf": [
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "start": {
                  "anyOf": [
                    {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "Z$|[+]00:00$"
                    },
                    {
                      "type": "null"
                    }
                  ]
                },
                "end": {
                  "anyOf": [
                    {
                      "type": "string",
                      "format": "date-time",
                      "pattern": "Z$|[+]00:00$"
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              },
              "required": [
                "start",
                "end"
              ]
            },
            {
              "type": "null"
            }
          ]
        },
        "uncertainty": {
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "pattern": "\\S"
              },
              "minItems": 0,
              "uniqueItems": true
            },
            {
              "type": "null"
            }
          ]
        },
        "limitations": {
          "anyOf": [
            {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "pattern": "\\S"
              },
              "minItems": 0,
              "uniqueItems": true
            },
            {
              "type": "null"
            }
          ]
        },
        "evidence": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/evidence"
          },
          "minItems": 1,
          "uniqueItems": false
        }
      },
      "required": [
        "claim_id",
        "record_version",
        "statement",
        "claim_type",
        "status",
        "platform_scope",
        "region_scope",
        "language_scope",
        "observed_period",
        "uncertainty",
        "limitations",
        "evidence"
      ]
    }
  }
}
