normalizeArray = (value) => {
  if (!value) return [];
  if (Array.isArray(value)) return value;
  if (typeof value === 'string') {
    return value.split(',').map(item => item.trim()).filter(Boolean);
  }
  return [];
}
@swagger
/api/key-regenerate:
  post:
    summary: Regenerate API key
    description: |
      Generates a new random API key for the application and updates the .env file.
      The previous API key will be invalidated immediately after generation.
      
      This API key can be used for programmatic access to the API endpoints
      by sending it in the `x-api-key` header of subsequent requests.
      
      **Security Notice**: This operation invalidates any existing API key.
      All systems using the previous key will need to be updated.
    tags:
      - System
      - Authentication
    security:
      - BearerAuth: []
    responses:
      200:
        description: API key regenerated successfully
        content:
          application/json:
            schema:
              type: object
              properties:
                success:
                  type: string
                  description: The newly generated API key
                  example: "3f7a8d6e2c1b5a9f8e7d6c5b4a3f2e1d0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a5"
      401:
        description: Unauthorized - JWT authentication required
        content:
          application/json:
            schema:
              type: object
              properties:
                error:
                  type: string
                  example: "Authentication required"
      500:
        description: Server error
        content:
          application/json:
            schema:
              type: object
              properties:
                error:
                  type: string
                  example: "Error regenerating API key"