{
  "openapi": "3.1.0",
  "info": {
    "title": "AdApt Users API",
    "version": "1.0.0",
    "description": "Read-only access to AdApt user profiles. Requires API key auth.",
    "contact": {
      "name": "AdApt Support",
      "url": "https://adapt.heynews.co"
    }
  },
  "servers": [
    {
      "url": "https://udgzuenkwsoilbrsuvzr.supabase.co/functions/v1",
      "description": "Production"
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer token using USERS_API_KEY"
      }
    },
    "schemas": {
      "User": {
        "type": "object",
        "properties": {
          "user_id": { "type": "string", "format": "uuid" },
          "email": { "type": "string", "format": "email" },
          "name": { "type": "string", "nullable": true },
          "avatar_url": { "type": "string", "nullable": true },
          "plan": { "type": "string", "enum": ["hobbyist", "pro", "publisher"] },
          "transformations_remaining": { "type": "integer" },
          "transformations_used_this_month": { "type": "integer" },
          "created_at": { "type": "string", "format": "date-time" }
        }
      }
    }
  },
  "security": [{ "ApiKeyAuth": [] }],
  "paths": {
    "/users-api": {
      "get": {
        "summary": "List or fetch user profiles",
        "parameters": [
          { "name": "user_id", "in": "query", "schema": { "type": "string", "format": "uuid" }, "description": "Fetch a single user by ID" },
          { "name": "search", "in": "query", "schema": { "type": "string" }, "description": "Search by email or name" },
          { "name": "page", "in": "query", "schema": { "type": "integer", "minimum": 1, "default": 1 } },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "minimum": 1, "maximum": 100, "default": 50 } }
        ],
        "responses": {
          "200": {
            "description": "User or paginated user list",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    { "$ref": "#/components/schemas/User" },
                    {
                      "type": "object",
                      "properties": {
                        "users": { "type": "array", "items": { "$ref": "#/components/schemas/User" } },
                        "page": { "type": "integer" },
                        "limit": { "type": "integer" },
                        "total": { "type": "integer" }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": { "description": "Unauthorized" },
          "404": { "description": "User not found" }
        }
      }
    }
  }
}
