{
  "$schema": "https://json-schema.org/draft-07/schema#",
  "$id": "https://multiflexi.eu/schema/credential-type.json",
  "schemaVersion": "1.1.0",
  "title": "MultiFlexi Credential Type Schema",
  "description": "Schema for defining credential types in MultiFlexi.",
  "type": "object",
  "required": ["code", "uuid", "name", "description", "fields", "version"],
  "properties": {
    "uuid": {
      "type": "string",
      "description": "Universally unique identifier for the credential type. (The name of Requirement provided)  "
    },
    "code": {
      "type": "string",
      "description": "Requirement name code for referencing this credential type.",
      "$comment": "AbraFlexi, SQL, mServer, Office365 etc."
    },
    "name": {
      "$ref": "#/$defs/localizedString",
      "description": "Human-readable name of the credential type."
    },
    "version": {
      "type": "string",
      "description": "Application version.",
      "pattern": "^(0|[1-9]\\d*)(\\.(0|[1-9]\\d*))?(\\.(0|[1-9]\\d*))?$",
      "examples": [
       "1",
       "1.2",
       "1.2.3"
      ]
    },
    "description": {
      "$ref": "#/$defs/localizedString",
      "description": "Detailed description of the credential type."
    },
    "fields": {
      "type": "array",
      "description": "List of fields required for this credential type.",
      "items": {
        "type": "object",
        "required": ["keyword", "name", "type"],
        "properties": {
          "keyword": {
            "type": "string",
            "description": "required keyword for internal reference.",
            "$comment": "For example DATABASE_PASSWORD or EASE_LOGGER"
          },
          "name": {
            "$ref": "#/$defs/localizedString",
            "description": "Field name."
          },
          "type": {
            "type": "string",
            "enum": [
              "string",
              "password",
              "number",
              "boolean",
              "secret",
              "select"
            ],
            "description": "Type of the field."
          },
          "description": {
            "$ref": "#/$defs/localizedString",
            "description": "Description of the field."
          },
          "required": {
            "type": "boolean",
            "description": "Whether this field is required."
          },
          "default": {
            "description": "Default value for the field."
          },
          "options": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Options for select fields."
          }
        }
      }
    },
    "localized": {
      "type": "object",
      "description": "Localized strings for multilanguage support.",
      "properties": {
        "name": {
          "type": "object",
          "additionalProperties": { "type": "string" }
        },
        "description": {
          "type": "object",
          "additionalProperties": { "type": "string" }
        }
      }
    }
  },
  "additionalProperties": false,
  "$defs": {
    "localizedString": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "object",
          "minProperties": 1,
          "properties": {
            "en": {
              "type": "string"
            },
            "cs": {
              "type": "string"
            },
            "sk": {
              "type": "string"
            },
            "de": {
              "type": "string"
            },
            "fr": {
              "type": "string"
            },
            "es": {
              "type": "string"
            },
            "it": {
              "type": "string"
            },
            "pl": {
              "type": "string"
            },
            "nl": {
              "type": "string"
            },
            "pt": {
              "type": "string"
            },
            "sv": {
              "type": "string"
            },
            "fi": {
              "type": "string"
            },
            "da": {
              "type": "string"
            },
            "no": {
              "type": "string"
            },
            "hu": {
              "type": "string"
            },
            "ro": {
              "type": "string"
            },
            "bg": {
              "type": "string"
            },
            "el": {
              "type": "string"
            },
            "tr": {
              "type": "string"
            },
            "hr": {
              "type": "string"
            },
            "sl": {
              "type": "string"
            },
            "et": {
              "type": "string"
            },
            "lt": {
              "type": "string"
            },
            "lv": {
              "type": "string"
            },
            "ru": {
              "type": "string"
            },
            "uk": {
              "type": "string"
            },
            "ja": {
              "type": "string"
            },
            "zh": {
              "type": "string"
            },
            "ko": {
              "type": "string"
            },
            "ar": {
              "type": "string"
            },
            "he": {
              "type": "string"
            },
            "hi": {
              "type": "string"
            }
          },
          "additionalProperties": false
        }
      ]
    }
  }
}
