{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://mimesia.com/schemas/badges.schema.json",
  "title": "Mimesia User Badges Index",
  "type": "object",
  "required": ["version", "user", "assertions"],
  "additionalProperties": false,
  "properties": {
    "version": {
      "type": "string",
      "enum": ["1.0"]
    },
    "updated": {
      "description": "Last update timestamp (UTC, RFC3339).",
      "type": "string",
      "format": "date-time"
    },
    "network": {
      "description": "Optional logical network(s) this index participates in.",
      "oneOf": [
        { "type": "string", "minLength": 1 },
        {
          "type": "array",
          "minItems": 0,
          "uniqueItems": true,
          "items": { "type": "string", "minLength": 1 }
        }
      ]
    },
    "user": {
      "description": "Owner of this badges.json file.",
      "type": "object",
      "required": ["username", "profile_url"],
      "additionalProperties": false,
      "properties": {
        "username": {
          "type": "string",
          "minLength": 1,
          "maxLength": 64,
          "pattern": "^[a-z0-9][a-z0-9._-]*$"
        },
        "display_name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200
        },
        "profile_url": {
          "type": "string",
          "format": "uri",
          "pattern": "^https://([a-z0-9.-]+\\.)?mimesia\\.name(/|$)"
        }
      }
    },
    "assertions": {
      "description": "List of authoritative Open Badges assertion URLs (any HTTPS domain).",
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string",
        "format": "uri",
        "pattern": "^https://"
      }
    },
    "badge_images": {
      "description": "Optional map from assertion URL → baked PNG/SVG mirror for display.",
      "type": "object",
      "additionalProperties": {
        "type": "string",
        "format": "uri",
        "pattern": "^https://.*\\.(png|svg)$"
      },
      "propertyNames": {
        "type": "string",
        "format": "uri",
        "pattern": "^https://"
      }
    },
    "labels": {
      "description": "Optional map from assertion URL → short human label for UI.",
      "type": "object",
      "additionalProperties": {
        "type": "string",
        "minLength": 1,
        "maxLength": 120
      },
      "propertyNames": {
        "type": "string",
        "format": "uri",
        "pattern": "^https://"
      }
    },
    "issuers": {
      "description": "Optional UX hints about known issuers (non-authoritative).",
      "type": "array",
      "uniqueItems": true,
      "items": {
        "type": "object",
        "required": ["id", "name"],
        "additionalProperties": false,
        "properties": {
          "id": {
            "description": "Issuer id URL used in Open Badges (must match Issuer.id).",
            "type": "string",
            "format": "uri",
            "pattern": "^https://"
          },
          "name": { "type": "string", "minLength": 1, "maxLength": 200 },
          "homepage": { "type": "string", "format": "uri" },
          "icon": {
            "description": "Small icon for UI.",
            "type": "string",
            "format": "uri",
            "pattern": "^https://.*\\.(png|svg)$"
          }
        }
      }
    },
    "links": {
      "description": "Optional convenience links for this user.",
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "collection": {
          "description": "User’s collection page on any project.",
          "type": "string",
          "format": "uri"
        },
        "feed": { "type": "string", "format": "uri" },
        "contact": { "type": "string", "format": "email" }
      }
    }
  }
}
