{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/auditae-app/json-schema/auditae-app-discovered-entity-schema.json",
  "title": "DiscoveredEntity",
  "x-generated": "2026-11-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/auditae-app-openapi.json#/components/schemas/DiscoveredEntity",
  "type": "object",
  "required": [
    "found",
    "domain_matched",
    "matched_by",
    "wikidata_qid",
    "label",
    "description",
    "official_site",
    "same_as",
    "detail",
    "candidates",
    "google_kg",
    "google_kg_status"
  ],
  "properties": {
    "found": {
      "type": "boolean"
    },
    "domain_matched": {
      "type": [
        "boolean",
        "null"
      ]
    },
    "matched_by": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "domain",
        "qid",
        null
      ]
    },
    "wikidata_qid": {
      "type": [
        "string",
        "null"
      ]
    },
    "label": {
      "type": [
        "string",
        "null"
      ]
    },
    "description": {
      "type": [
        "string",
        "null"
      ]
    },
    "official_site": {
      "type": [
        "string",
        "null"
      ]
    },
    "same_as": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Profile URLs for the Organization's sameAs."
    },
    "detail": {
      "type": "object",
      "additionalProperties": {
        "type": [
          "string",
          "null"
        ]
      }
    },
    "candidates": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/EntityCandidate"
      }
    },
    "google_kg": {
      "oneOf": [
        {
          "$ref": "#/$defs/GoogleKgEntity"
        },
        {
          "type": "null"
        }
      ],
      "description": "Matched by domain or by the Wikidata item's KG id, never by name alone."
    },
    "google_kg_status": {
      "type": "string",
      "enum": [
        "matched",
        "not_confirmed",
        "unavailable"
      ],
      "description": "not_confirmed: no KG result could be tied to the brand by domain or Wikidata id; Google may still have an entity. unavailable: the lookup couldn't run."
    },
    "site_same_as": {
      "type": "array",
      "description": "With a domain: the sameAs URLs the site's own homepage JSON-LD declares, each checked live. Resolving ones are safe to keep in sameAs.",
      "items": {
        "type": "object",
        "required": [
          "url",
          "resolves",
          "status"
        ],
        "properties": {
          "url": {
            "type": "string"
          },
          "resolves": {
            "type": "boolean",
            "description": "It answered, or refused a bot the way profile sites do (401/403/429/999)."
          },
          "status": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      }
    },
    "next_step": {
      "type": "string"
    }
  },
  "$defs": {
    "EntityCandidate": {
      "type": "object",
      "required": [
        "qid",
        "label",
        "description",
        "official_site",
        "domain_matched"
      ],
      "properties": {
        "qid": {
          "type": "string"
        },
        "label": {
          "type": "string"
        },
        "description": {
          "type": [
            "string",
            "null"
          ]
        },
        "official_site": {
          "type": [
            "string",
            "null"
          ]
        },
        "domain_matched": {
          "type": [
            "boolean",
            "null"
          ]
        }
      }
    },
    "GoogleKgEntity": {
      "type": "object",
      "description": "The brand's entity in Google's Knowledge Graph.",
      "required": [
        "kg_id",
        "name",
        "types",
        "description",
        "detailed_description_url",
        "url",
        "result_score",
        "domain_matched",
        "wikidata_id_matched"
      ],
      "properties": {
        "kg_id": {
          "type": "string",
          "description": "Knowledge Graph id, e.g. /m/027cz92 or /g/11…"
        },
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "types": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "description": {
          "type": [
            "string",
            "null"
          ]
        },
        "detailed_description_url": {
          "type": [
            "string",
            "null"
          ],
          "description": "Usually the entity's Wikipedia article."
        },
        "url": {
          "type": [
            "string",
            "null"
          ],
          "description": "The website Google lists for the entity."
        },
        "result_score": {
          "type": [
            "number",
            "null"
          ],
          "description": "Google's relevance score; 0 when found by id."
        },
        "domain_matched": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "url's host is the domain. null without a domain or a url."
        },
        "wikidata_id_matched": {
          "type": [
            "boolean",
            "null"
          ],
          "description": "kg_id is the matched Wikidata item's Google KG (P2671) or Freebase (P646) id. null when there's none."
        }
      }
    }
  }
}