{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://soqver.com/spec/so4ag/0.1/profile.schema.json",
  "title": "SO4AG 0.1 profile",
  "description": "A profile defines properties and scope keys. Anyone may publish one at an HTTPS address; a source lists the address in profiles.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "name",
    "version",
    "namespace",
    "scope_keys",
    "properties"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uri",
      "pattern": "^https://",
      "maxLength": 500
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "version": {
      "type": "string",
      "minLength": 1,
      "maxLength": 50
    },
    "status": {
      "type": "string",
      "maxLength": 50
    },
    "description": {
      "type": "string",
      "maxLength": 2000
    },
    "namespace": {
      "type": "string",
      "format": "uri",
      "pattern": "^https://.*[#/]$",
      "maxLength": 500
    },
    "scope_keys": {
      "type": "object",
      "maxProperties": 60,
      "propertyNames": {
        "pattern": "^[a-z][a-z0-9_]{0,39}$"
      },
      "additionalProperties": {
        "type": "string",
        "minLength": 1,
        "maxLength": 500
      }
    },
    "properties": {
      "type": "object",
      "minProperties": 1,
      "maxProperties": 300,
      "propertyNames": {
        "pattern": "^[A-Za-z][A-Za-z0-9_]{0,79}$"
      },
      "additionalProperties": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "label",
          "value_types",
          "description"
        ],
        "properties": {
          "label": {
            "type": "object",
            "required": [
              "en"
            ],
            "additionalProperties": {
              "type": "string",
              "minLength": 1,
              "maxLength": 200
            }
          },
          "value_types": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "enum": [
                "money",
                "quantity",
                "boolean",
                "text",
                "enum",
                "enum_set",
                "organization",
                "place"
              ]
            }
          },
          "units": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 20
            }
          },
          "enum": {
            "type": "array",
            "minItems": 1,
            "uniqueItems": true,
            "items": {
              "type": "string",
              "pattern": "^[a-z0-9_]{1,60}$"
            }
          },
          "required_scope": {
            "type": "array",
            "uniqueItems": true,
            "items": {
              "type": "string"
            }
          },
          "max_validity": {
            "type": "string",
            "pattern": "^P(?!$)([0-9]+Y)?([0-9]+M)?([0-9]+W)?([0-9]+D)?(T([0-9]+H)?([0-9]+M)?([0-9]+S)?)?$"
          },
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1000
          },
          "same_as": {
            "type": "string",
            "format": "uri",
            "maxLength": 500
          },
          "live": {
            "type": "boolean",
            "description": "A live fact (section 8): short validity, unknown without a live connection."
          }
        }
      }
    }
  }
}