{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://fleet.forgesdlc.com/schemas/requirement-templates.schema.json",
  "title": "Forge Fleet requirement templates document",
  "type": "object",
  "additionalProperties": false,
  "required": ["version", "templates"],
  "properties": {
    "version": { "type": "integer", "minimum": 1 },
    "templates": {
      "type": "array",
      "items": { "$ref": "#/$defs/template" }
    }
  },
  "$defs": {
    "templateId": { "type": "string", "pattern": "^[a-z][a-z0-9_-]{0,63}$" },
    "template": {
      "type": "object",
      "additionalProperties": false,
      "required": ["id", "title", "kind", "ref"],
      "properties": {
        "id": { "$ref": "#/$defs/templateId" },
        "title": { "type": "string", "minLength": 1, "maxLength": 200 },
        "kind": { "enum": ["dockerfile", "image"] },
        "ref": { "type": "string", "minLength": 1, "maxLength": 254 },
        "notes": { "type": "string", "maxLength": 4000 },
        "image_semver": { "type": "string", "maxLength": 64, "pattern": "^[a-zA-Z0-9._+v~-]+$" }
      },
      "allOf": [
        {
          "if": { "properties": { "kind": { "const": "dockerfile" } } },
          "then": { "not": { "required": ["image_semver"] } }
        }
      ]
    }
  }
}
