{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://qhsetech.com/data/software.schema.json",
  "title": "QHSEtech researched software export",
  "description": "Validates the export envelope and core evidence fields, not the truth or freshness of claims. Additional legacy metadata may be present.",
  "type": "object",
  "required": [
    "name",
    "license",
    "software"
  ],
  "properties": {
    "name": {
      "type": "string"
    },
    "license": {
      "type": "string",
      "format": "uri"
    },
    "as_of": {
      "type": "string",
      "description": "Legacy snapshot date; use per-profile evidence dates."
    },
    "software": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "name",
          "url",
          "evidence_status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "minLength": 1
          },
          "name": {
            "type": "string",
            "minLength": 1
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "evidence_checked_on": {
            "type": "string",
            "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
          },
          "sources": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "array",
              "prefixItems": [
                {
                  "type": "string"
                },
                {
                  "type": "string",
                  "format": "uri"
                }
              ],
              "minItems": 2,
              "maxItems": 2
            }
          },
          "rating": {
            "type": [
              "number",
              "null"
            ]
          },
          "review_count": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "evidence_status": {
            "enum": [
              "vendor-sources-reviewed",
              "pending-review"
            ]
          },
          "offering_type": {
            "type": "string",
            "enum": [
              "software",
              "document-templates"
            ],
            "description": "Distinguishes document-template products from software applications."
          }
        },
        "additionalProperties": true,
        "allOf": [
          {
            "if": {
              "properties": {
                "evidence_status": {
                  "const": "vendor-sources-reviewed"
                }
              }
            },
            "then": {
              "required": [
                "sources",
                "evidence_checked_on"
              ]
            }
          }
        ]
      }
    }
  },
  "additionalProperties": true
}
