{
  "openapi": "3.0.3",
  "info": {
    "title": "AGLIS Warehouse Management API",
    "description": "Dokumentasi REST API Sistem Manajemen Stok & Logistik Gudang (AGLIS NET • PT Gapura Era Digital). Dilengkapi otentikasi Cookie Session & HTTP Basic Auth dengan Role-Based Access Control (RBAC: viewer, operator, manager, admin).",
    "version": "1.0.0",
    "contact": {
      "name": "NOC AGLIS NET",
      "email": "noc@aglis.biz.id"
    }
  },
  "servers": [
    {
      "url": "https://warehouse.aglis.biz.id",
      "description": "Production Server"
    },
    {
      "url": "http://dev-wh.aglis.biz.id",
      "description": "Development Server"
    },
    {
      "url": "http://localhost:9155",
      "description": "Local Development"
    }
  ],
  "tags": [
    { "name": "System & Health", "description": "Status kesehatan aplikasi dan audit log sistem" },
    { "name": "Authentication", "description": "Autentikasi login, logout, dan identitas sesi" },
    { "name": "Dashboard", "description": "Ringkasan statistik stok, valuta inventaris, dan peringatan stok menipis" },
    { "name": "Barang (Items)", "description": "Katalog master barang, SKU, harga, stok, dan import batch Excel" },
    { "name": "Transaksi", "description": "Pencatatan mutasi barang masuk (IN), keluar (OUT), dan opname koreksi (ADJUSTMENT)" },
    { "name": "Master Data", "description": "Kelola master kategori, lokasi/rak gudang, dan supplier/distributor" },
    { "name": "User Management", "description": "Kelola akun pengguna, hak akses peran (RBAC), dan status aktif (Admin Only)" }
  ],
  "components": {
    "securitySchemes": {
      "cookieAuth": {
        "type": "apiKey",
        "in": "cookie",
        "name": "aglis_session",
        "description": "Session cookie yang diperoleh setelah login melalui POST /api/auth/login"
      },
      "basicAuth": {
        "type": "http",
        "scheme": "basic",
        "description": "HTTP Basic Authentication menggunakan username dan password pengguna terdaftar"
      }
    },
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": { "type": "string", "example": "Pesan error" }
        }
      },
      "User": {
        "type": "object",
        "properties": {
          "username": { "type": "string", "example": "operator1" },
          "role": { "type": "string", "enum": ["viewer", "operator", "manager", "admin"], "example": "operator" },
          "enabled": { "type": "boolean", "example": true }
        }
      },
      "Item": {
        "type": "object",
        "properties": {
          "id": { "type": "integer", "example": 1 },
          "sku": { "type": "string", "example": "MODEM-HG680P" },
          "name": { "type": "string", "example": "STB Fiberhome HG680P" },
          "category_id": { "type": "integer", "example": 2 },
          "category_name": { "type": "string", "example": "CPE & Modem" },
          "location_id": { "type": "integer", "example": 1 },
          "location_name": { "type": "string", "example": "Rak A-01" },
          "quantity": { "type": "integer", "example": 25 },
          "min_stock": { "type": "integer", "example": 5 },
          "unit": { "type": "string", "example": "Unit" },
          "price": { "type": "number", "example": 175000 },
          "description": { "type": "string", "example": "STB Android 4K" },
          "created_at": { "type": "string", "example": "2026-10-01 10:00:00" },
          "updated_at": { "type": "string", "example": "2026-10-14 12:00:00" }
        }
      },
      "Category": {
        "type": "object",
        "properties": {
          "id": { "type": "integer", "example": 1 },
          "name": { "type": "string", "example": "Kabel & Aksesoris" },
          "description": { "type": "string", "example": "Kabel dropcore, patchcord, pigtail" }
        }
      },
      "Location": {
        "type": "object",
        "properties": {
          "id": { "type": "integer", "example": 1 },
          "name": { "type": "string", "example": "Rak A-01" },
          "description": { "type": "string", "example": "Gudang Utama Lantai 1" }
        }
      },
      "Supplier": {
        "type": "object",
        "properties": {
          "id": { "type": "integer", "example": 1 },
          "name": { "type": "string", "example": "PT Optik Nusantara" },
          "contact": { "type": "string", "example": "081234567890" },
          "address": { "type": "string", "example": "Jakarta Barat" }
        }
      },
      "Transaction": {
        "type": "object",
        "properties": {
          "id": { "type": "integer", "example": 10 },
          "reference_no": { "type": "string", "example": "TRX-20261014-001" },
          "type": { "type": "string", "enum": ["IN", "OUT", "ADJUSTMENT"], "example": "IN" },
          "party": { "type": "string", "example": "PT Optik Nusantara" },
          "notes": { "type": "string", "example": "Pengadaan batch Q4" },
          "created_by": { "type": "string", "example": "operator1 (operator)" },
          "created_at": { "type": "string", "example": "2026-10-14 14:00:00" },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "item_id": { "type": "integer", "example": 1 },
                "item_name": { "type": "string", "example": "STB Fiberhome HG680P" },
                "quantity": { "type": "integer", "example": 10 },
                "price": { "type": "number", "example": 175000 }
              }
            }
          }
        }
      }
    }
  },
  "security": [
    { "cookieAuth": [] },
    { "basicAuth": [] }
  ],
  "paths": {
    "/health": {
      "get": {
        "tags": ["System & Health"],
        "summary": "Health check service",
        "description": "Memeriksa status hidup server aplikasi gudang.",
        "security": [],
        "responses": {
          "200": {
            "description": "Server online dan database responsif",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string", "example": "healthy" },
                    "timestamp": { "type": "string", "example": "2026-10-14T12:00:00.000Z" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/auth/login": {
      "post": {
        "tags": ["Authentication"],
        "summary": "Login pengguna",
        "description": "Mengotentikasi pengguna menggunakan username & password. Menghasilkan cookie sesi `aglis_session`.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["username", "password"],
                "properties": {
                  "username": { "type": "string", "example": "admin" },
                  "password": { "type": "string", "format": "password", "example": "rahasia123" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Login berhasil",
            "headers": {
              "Set-Cookie": {
                "schema": { "type": "string", "example": "aglis_session=...; Path=/; HttpOnly; SameSite=Lax; Secure" }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": { "type": "string", "example": "Login successful" },
                    "user": { "$ref": "#/components/schemas/User" }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Username atau password salah / akun nonaktif",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } }
          }
        }
      }
    },
    "/api/auth/logout": {
      "post": {
        "tags": ["Authentication"],
        "summary": "Logout pengguna",
        "description": "Menghapus cookie sesi `aglis_session`.",
        "responses": {
          "200": {
            "description": "Logout berhasil",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": { "type": "string", "example": "Logged out" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/me": {
      "get": {
        "tags": ["Authentication"],
        "summary": "Profil sesi aktif",
        "description": "Mengembalikan data pengguna yang sedang login saat ini.",
        "responses": {
          "200": {
            "description": "Identitas pengguna aktif",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/User" }
              }
            }
          },
          "401": {
            "description": "Belum terotentikasi",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorResponse" } } }
          }
        }
      }
    },
    "/api/audit-logs": {
      "get": {
        "tags": ["System & Health"],
        "summary": "Daftar Audit Log (Admin Only)",
        "description": "Melihat riwayat aktivitas perubahan data (CREATE, UPDATE, DELETE). Hanya untuk role `admin`.",
        "parameters": [
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 50 } },
          { "name": "offset", "in": "query", "schema": { "type": "integer", "default": 0 } },
          { "name": "action", "in": "query", "schema": { "type": "string", "enum": ["CREATE", "UPDATE", "DELETE"] } },
          { "name": "entity", "in": "query", "schema": { "type": "string" } },
          { "name": "username", "in": "query", "schema": { "type": "string" } }
        ],
        "responses": {
          "200": {
            "description": "Daftar log aktivitas",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total": { "type": "integer", "example": 120 },
                    "rows": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": { "type": "integer" },
                          "action": { "type": "string" },
                          "entity": { "type": "string" },
                          "entity_id": { "type": "string" },
                          "details": { "type": "string" },
                          "username": { "type": "string" },
                          "ip_address": { "type": "string" },
                          "created_at": { "type": "string" }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "403": { "description": "Insufficient role (wajib admin)" }
        }
      }
    },
    "/api/dashboard/summary": {
      "get": {
        "tags": ["Dashboard"],
        "summary": "Ringkasan statistik gudang",
        "description": "Menampilkan total jenis item, total kuantitas stok fisik, total estimasi nilai valuasi aset, dan jumlah item yang menipis.",
        "responses": {
          "200": {
            "description": "Statistik ringkasan stok",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total_items": { "type": "integer", "example": 45 },
                    "total_quantity": { "type": "integer", "example": 1250 },
                    "total_asset_value": { "type": "number", "example": 48500000 },
                    "low_stock_count": { "type": "integer", "example": 3 }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/dashboard/low-stock": {
      "get": {
        "tags": ["Dashboard"],
        "summary": "Peringatan barang menipis",
        "description": "Daftar barang yang kuantitas stoknya di bawah atau sama dengan `min_stock`.",
        "responses": {
          "200": {
            "description": "Daftar barang low-stock",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": { "$ref": "#/components/schemas/Item" }
                }
              }
            }
          }
        }
      }
    },
    "/api/items": {
      "get": {
        "tags": ["Barang (Items)"],
        "summary": "Katalog semua barang",
        "description": "Mengambil seluruh daftar barang beserta nama kategori dan lokasinya.",
        "responses": {
          "200": {
            "description": "Katalog barang",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": { "$ref": "#/components/schemas/Item" }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": ["Barang (Items)"],
        "summary": "Tambah barang baru (Manager & Admin)",
        "description": "Menambahkan data barang master baru ke gudang.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["sku", "name", "category_id", "location_id"],
                "properties": {
                  "sku": { "type": "string", "example": "MODEM-HG680P" },
                  "name": { "type": "string", "example": "STB Fiberhome HG680P" },
                  "category_id": { "type": "integer", "example": 2 },
                  "location_id": { "type": "integer", "example": 1 },
                  "quantity": { "type": "integer", "default": 0, "example": 10 },
                  "min_stock": { "type": "integer", "default": 5, "example": 5 },
                  "unit": { "type": "string", "default": "pcs", "example": "Unit" },
                  "price": { "type": "number", "default": 0, "example": 175000 },
                  "description": { "type": "string", "example": "STB Android 4K" }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Barang berhasil dibuat",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": { "type": "integer", "example": 12 },
                    "message": { "type": "string", "example": "Item created successfully" }
                  }
                }
              }
            }
          },
          "400": { "description": "Parameter tidak lengkap / SKU duplikat" },
          "403": { "description": "Insufficient role (minimal manager)" }
        }
      }
    },
    "/api/items/{id}": {
      "get": {
        "tags": ["Barang (Items)"],
        "summary": "Detail barang berdasarkan ID",
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }
        ],
        "responses": {
          "200": {
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Item" } } }
          },
          "404": { "description": "Barang tidak ditemukan" }
        }
      },
      "put": {
        "tags": ["Barang (Items)"],
        "summary": "Update data barang (Manager & Admin)",
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "sku": { "type": "string" },
                  "name": { "type": "string" },
                  "category_id": { "type": "integer" },
                  "location_id": { "type": "integer" },
                  "min_stock": { "type": "integer" },
                  "unit": { "type": "string" },
                  "price": { "type": "number" },
                  "description": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Barang berhasil diperbarui" },
          "400": { "description": "Data tidak valid" },
          "403": { "description": "Insufficient role" }
        }
      },
      "delete": {
        "tags": ["Barang (Items)"],
        "summary": "Hapus barang (Admin Only)",
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }
        ],
        "responses": {
          "200": { "description": "Barang berhasil dihapus" },
          "400": { "description": "Barang memiliki riwayat transaksi aktif" },
          "403": { "description": "Insufficient role (admin only)" }
        }
      }
    },
    "/api/items/import-batch": {
      "post": {
        "tags": ["Barang (Items)"],
        "summary": "Import data barang massal via JSON/Excel (Manager & Admin)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["rows"],
                "properties": {
                  "upsert": { "type": "boolean", "default": false, "description": "Jika true, SKU duplikat akan diupdate" },
                  "rows": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": ["sku", "name"],
                      "properties": {
                        "sku": { "type": "string" },
                        "name": { "type": "string" },
                        "category": { "type": "string" },
                        "location": { "type": "string" },
                        "quantity": { "type": "integer" },
                        "min_stock": { "type": "integer" },
                        "unit": { "type": "string" },
                        "price": { "type": "number" },
                        "description": { "type": "string" }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Laporan hasil impor",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "total": { "type": "integer" },
                    "created": { "type": "integer" },
                    "updated": { "type": "integer" },
                    "skipped": { "type": "integer" },
                    "errors": { "type": "array", "items": { "type": "object" } }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/transactions": {
      "get": {
        "tags": ["Transaksi"],
        "summary": "Riwayat transaksi mutasi barang",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": { "$ref": "#/components/schemas/Transaction" }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": ["Transaksi"],
        "summary": "Buat transaksi mutasi stok (Operator, Manager, Admin)",
        "description": "Mencatat transaksi IN (masuk), OUT (keluar), atau ADJUSTMENT (opname selisih stok). Eksekusi atomic per batch item.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["type", "items"],
                "properties": {
                  "type": { "type": "string", "enum": ["IN", "OUT", "ADJUSTMENT"], "example": "IN" },
                  "party": { "type": "string", "example": "PT Optik Nusantara" },
                  "notes": { "type": "string", "example": "Restock bulanan" },
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": ["item_id", "quantity"],
                      "properties": {
                        "item_id": { "type": "integer", "example": 1 },
                        "quantity": { "type": "integer", "example": 10 },
                        "price": { "type": "number", "example": 175000 }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Transaksi berhasil disimpan",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "transaction_id": { "type": "integer", "example": 15 },
                    "reference_no": { "type": "string", "example": "TRX-20261014-001" },
                    "message": { "type": "string", "example": "Transaction recorded successfully" }
                  }
                }
              }
            }
          },
          "400": { "description": "Stok tidak mencukupi untuk transaksi OUT atau item invalid" }
        }
      }
    },
    "/api/transactions/{id}": {
      "get": {
        "tags": ["Transaksi"],
        "summary": "Detail transaksi beserta rincian item",
        "parameters": [
          { "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }
        ],
        "responses": {
          "200": {
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Transaction" } } }
          },
          "404": { "description": "Transaksi tidak ditemukan" }
        }
      }
    },
    "/api/categories": {
      "get": {
        "tags": ["Master Data"],
        "summary": "Daftar master kategori",
        "responses": {
          "200": {
            "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Category" } } } }
          }
        }
      },
      "post": {
        "tags": ["Master Data"],
        "summary": "Tambah kategori (Manager & Admin)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["name"],
                "properties": {
                  "name": { "type": "string", "example": "Kabel & Aksesoris" },
                  "description": { "type": "string", "example": "Kabel dropcore, patchcord" }
                }
              }
            }
          }
        },
        "responses": { "201": { "description": "Kategori berhasil dibuat" } }
      }
    },
    "/api/categories/{id}": {
      "put": {
        "tags": ["Master Data"],
        "summary": "Update kategori (Manager & Admin)",
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": { "name": { "type": "string" }, "description": { "type": "string" } }
              }
            }
          }
        },
        "responses": { "200": { "description": "Kategori berhasil diperbarui" } }
      },
      "delete": {
        "tags": ["Master Data"],
        "summary": "Hapus kategori (Manager & Admin)",
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }],
        "responses": { "200": { "description": "Kategori berhasil dihapus" } }
      }
    },
    "/api/locations": {
      "get": {
        "tags": ["Master Data"],
        "summary": "Daftar master lokasi/rak",
        "responses": {
          "200": {
            "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Location" } } } }
          }
        }
      },
      "post": {
        "tags": ["Master Data"],
        "summary": "Tambah lokasi/rak (Manager & Admin)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["name"],
                "properties": {
                  "name": { "type": "string", "example": "Rak B-02" },
                  "description": { "type": "string", "example": "Gudang Barat" }
                }
              }
            }
          }
        },
        "responses": { "201": { "description": "Lokasi berhasil dibuat" } }
      }
    },
    "/api/locations/{id}": {
      "put": {
        "tags": ["Master Data"],
        "summary": "Update lokasi (Manager & Admin)",
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": { "name": { "type": "string" }, "description": { "type": "string" } }
              }
            }
          }
        },
        "responses": { "200": { "description": "Lokasi berhasil diperbarui" } }
      },
      "delete": {
        "tags": ["Master Data"],
        "summary": "Hapus lokasi (Manager & Admin)",
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }],
        "responses": { "200": { "description": "Lokasi berhasil dihapus" } }
      }
    },
    "/api/suppliers": {
      "get": {
        "tags": ["Master Data"],
        "summary": "Daftar supplier/distributor",
        "responses": {
          "200": {
            "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Supplier" } } } }
          }
        }
      },
      "post": {
        "tags": ["Master Data"],
        "summary": "Tambah supplier (Manager & Admin)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["name"],
                "properties": {
                  "name": { "type": "string", "example": "PT Optik Nusantara" },
                  "contact": { "type": "string", "example": "081234567890" },
                  "address": { "type": "string", "example": "Jakarta Barat" }
                }
              }
            }
          }
        },
        "responses": { "201": { "description": "Supplier berhasil dibuat" } }
      }
    },
    "/api/suppliers/{id}": {
      "put": {
        "tags": ["Master Data"],
        "summary": "Update supplier (Manager & Admin)",
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": { "name": { "type": "string" }, "contact": { "type": "string" }, "address": { "type": "string" } }
              }
            }
          }
        },
        "responses": { "200": { "description": "Supplier berhasil diperbarui" } }
      },
      "delete": {
        "tags": ["Master Data"],
        "summary": "Hapus supplier (Manager & Admin)",
        "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "integer" } }],
        "responses": { "200": { "description": "Supplier berhasil dihapus" } }
      }
    },
    "/api/users": {
      "get": {
        "tags": ["User Management"],
        "summary": "Daftar pengguna terdaftar (Admin Only)",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": { "$ref": "#/components/schemas/User" }
                }
              }
            }
          },
          "403": { "description": "Insufficient role (admin only)" }
        }
      },
      "post": {
        "tags": ["User Management"],
        "summary": "Buat akun pengguna baru (Admin Only)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["username", "password", "role"],
                "properties": {
                  "username": { "type": "string", "example": "op_lapangan" },
                  "password": { "type": "string", "format": "password", "example": "KataSandi123" },
                  "role": { "type": "string", "enum": ["viewer", "operator", "manager", "admin"], "example": "operator" }
                }
              }
            }
          }
        },
        "responses": {
          "201": { "description": "User created" },
          "400": { "description": "Username sudah ada atau parameter invalid" },
          "403": { "description": "Insufficient role" }
        }
      }
    },
    "/api/users/{username}": {
      "put": {
        "tags": ["User Management"],
        "summary": "Update akun pengguna (Admin Only)",
        "description": "Mengubah peran (role), password, atau status enabled pengguna.",
        "parameters": [
          { "name": "username", "in": "path", "required": true, "schema": { "type": "string" } }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "role": { "type": "string", "enum": ["viewer", "operator", "manager", "admin"] },
                  "password": { "type": "string", "format": "password" },
                  "enabled": { "type": "boolean" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "User updated" },
          "400": { "description": "User tidak ditemukan atau role invalid" },
          "403": { "description": "Insufficient role" }
        }
      },
      "delete": {
        "tags": ["User Management"],
        "summary": "Hapus akun pengguna (Admin Only)",
        "parameters": [
          { "name": "username", "in": "path", "required": true, "schema": { "type": "string" } }
        ],
        "responses": {
          "200": { "description": "User deleted" },
          "400": { "description": "Akun utama admin tidak dapat dihapus" },
          "403": { "description": "Insufficient role" }
        }
      }
    }
  }
}
