{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "$id": "https://artifacts.apis.io/folio/json-schema/folio-capability-schema.json",
  "title": "Capability Set Object Schema",
  "description": "Object containing details of a capability",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/folio-capability-api-openapi.yml#/components/schemas/capability",
  "type": "object",
  "properties": {
    "id": {
      "description": "A unique identifier for this capability",
      "type": "string",
      "format": "uuid"
    },
    "name": {
      "description": "a human-readable name/label for this capability.  Takes the form of {resourceName}.{scope}, e.g. item.create",
      "type": "string",
      "readOnly": true
    },
    "description": {
      "description": "Free form description of the capability",
      "type": "string"
    },
    "resource": {
      "description": "The resource this capability is associated with, e.g. item",
      "type": "string",
      "pattern": "^[A-Za-z\\s]+$"
    },
    "action": {
      "description": "The action this capability is associated with, e.g. create",
      "$ref": "#/$defs/capabilityAction"
    },
    "applicationId": {
      "description": "The id of the application which defines the capability",
      "type": "string"
    },
    "moduleId": {
      "description": "The id of the module which defines the capability",
      "type": "string"
    },
    "permission": {
      "description": "Folio permission name",
      "type": "string"
    },
    "endpoints": {
      "type": "array",
      "description": "List of assigned endpoints",
      "items": {
        "$ref": "#/$defs/endpoint"
      }
    },
    "dummyCapability": {
      "description": "Is capability dummy",
      "type": "boolean"
    },
    "type": {
      "description": "The type of capability",
      "$ref": "#/$defs/capabilityType"
    },
    "metadata": {
      "$ref": "#/$defs/metadata",
      "readOnly": true
    },
    "visible": {
      "description": "Is visible in UI",
      "type": "boolean"
    },
    "direct": {
      "description": "Indicates whether the capability was directly assigned to the role (true) or inherited via a capability set (false). Populated only by GET /roles/{id}/capabilities.",
      "type": "boolean",
      "readOnly": true
    }
  },
  "required": [
    "resource",
    "action",
    "permissions",
    "type",
    "applicationId"
  ],
  "$defs": {
    "capabilityAction": {
      "$schema": "http://json-schema.org/draft-04/schema#",
      "description": "The action this capability is associated with, e.g. create",
      "type": "string",
      "enum": [
        "view",
        "create",
        "edit",
        "delete",
        "manage",
        "execute"
      ]
    },
    "capabilityType": {
      "$schema": "http://json-schema.org/draft-04/schema#",
      "description": "The type of capability",
      "type": "string",
      "enum": [
        "settings",
        "data",
        "procedural"
      ]
    },
    "endpoint": {
      "$schema": "http://json-schema.org/draft-04/schema#",
      "type": "object",
      "id": "endpoint.json",
      "description": "Object containing the details of the http-endpoint.",
      "properties": {
        "path": {
          "type": "string",
          "description": "Endpoint's static path / expression"
        },
        "method": {
          "description": "Http Method",
          "$ref": "#/$defs/httpMethod"
        }
      }
    },
    "httpMethod": {
      "$schema": "http://json-schema.org/draft-04/schema#",
      "description": "Http Method",
      "type": "string",
      "enum": [
        "GET",
        "HEAD",
        "POST",
        "PUT",
        "PATCH",
        "DELETE",
        "OPTIONS",
        "TRACE"
      ]
    },
    "metadata": {
      "$schema": "http://json-schema.org/draft-04/schema#",
      "title": "Metadata Schema",
      "description": "Metadata about creation and changes to records, provided by the server (client should not provide)",
      "type": "object",
      "properties": {
        "createdDate": {
          "description": "Date and time when the record was created",
          "type": "string",
          "format": "date-time"
        },
        "createdByUserId": {
          "description": "ID of the user who created the record (when available)",
          "type": "string",
          "format": "uuid"
        },
        "updatedDate": {
          "description": "Date and time when the record was last updated",
          "type": "string",
          "format": "date-time"
        },
        "updatedByUserId": {
          "description": "ID of the user who last updated the record (when available)",
          "type": "string",
          "format": "uuid"
        }
      },
      "additionalProperties": false
    }
  }
}