{
  "openapi": "3.0.3",
  "info": {
    "title": "RAFZ UPLOADER API",
    "version": "1.0.0",
    "description": "REST API publik untuk upload image & video. Tanpa API key, tanpa autentikasi, response JSON. Cocok untuk scraping, bot, automation, dan integrasi web/mobile.",
    "contact": {
      "name": "RAFZ UPLOADER",
      "url": "https://rafzuploader.lovable.app"
    },
    "license": {
      "name": "Free to use (non-illegal content)"
    }
  },
  "servers": [
    { "url": "https://rafzuploader.lovable.app", "description": "Production" }
  ],
  "tags": [
    { "name": "Upload", "description": "Upload file image/video" },
    { "name": "File", "description": "Akses file yang sudah diupload" }
  ],
  "paths": {
    "/api/public/upload": {
      "post": {
        "tags": ["Upload"],
        "summary": "Upload sebuah file image atau video",
        "description": "Menerima file via multipart/form-data dan mengembalikan URL publik permanen. Max 50MB untuk image, 100MB untuk video.",
        "operationId": "uploadFile",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": ["file"],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "File image (jpg, png, webp, gif) atau video (mp4, mov, webm)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Upload berhasil",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/UploadSuccess" },
                "example": {
                  "success": true,
                  "filename": "image.jpg",
                  "size": 123456,
                  "url": "https://rafzuploader.lovable.app/f/images/abc123.jpg"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request — field 'file' tidak ditemukan",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" },
                "example": { "success": false, "error": "No file provided" }
              }
            }
          },
          "413": {
            "description": "Payload Too Large — ukuran melebihi limit",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" },
                "example": { "success": false, "error": "File too large" }
              }
            }
          },
          "415": {
            "description": "Unsupported Media Type",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" },
                "example": { "success": false, "error": "Unsupported file type" }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      },
      "options": {
        "tags": ["Upload"],
        "summary": "CORS preflight",
        "responses": {
          "204": { "description": "No Content" }
        }
      }
    },
    "/f/{folder}/{filename}": {
      "get": {
        "tags": ["File"],
        "summary": "Ambil file yang sudah diupload",
        "description": "Mengembalikan binary file dengan Content-Type sesuai MIME asli dan cache header immutable.",
        "operationId": "getFile",
        "parameters": [
          {
            "name": "folder",
            "in": "path",
            "required": true,
            "schema": { "type": "string", "enum": ["images", "videos"] },
            "description": "Folder file (images atau videos)."
          },
          {
            "name": "filename",
            "in": "path",
            "required": true,
            "schema": { "type": "string", "example": "abc123def456.jpg" },
            "description": "Nama file (UUID 16 karakter + ekstensi)."
          }
        ],
        "responses": {
          "200": {
            "description": "File ditemukan",
            "content": {
              "image/*": { "schema": { "type": "string", "format": "binary" } },
              "video/*": { "schema": { "type": "string", "format": "binary" } }
            }
          },
          "404": { "description": "File tidak ditemukan" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "UploadSuccess": {
        "type": "object",
        "required": ["success", "filename", "size", "url"],
        "properties": {
          "success": { "type": "boolean", "example": true },
          "filename": { "type": "string", "description": "Nama file asli", "example": "image.jpg" },
          "size": { "type": "integer", "description": "Ukuran file dalam bytes", "example": 123456 },
          "url": { "type": "string", "format": "uri", "description": "URL publik permanen", "example": "https://rafzuploader.lovable.app/f/images/abc123.jpg" }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": ["success", "error"],
        "properties": {
          "success": { "type": "boolean", "example": false },
          "error": { "type": "string", "example": "File too large" }
        }
      }
    }
  }
}