{
  "openapi": "3.0.0",
  "info": {
    "title": "FileMaker WebViewer API",
    "description": "API for displaying FileMaker data with enhanced UI/UX capabilities",
    "version": "1.0.0",
    "contact": {
      "name": "API Support",
      "email": "support@example.com"
    }
  },
  "servers": [
    {
      "url": "http://localhost:3000/api",
      "description": "Development server"
    },
    {
      "url": "/api",
      "description": "Production server"
    }
  ],
  "paths": {
    "/activities": {
      "get": {
        "tags": ["Activities"],
        "summary": "Get all activities with pagination",
        "description": "Retrieve a paginated list of activities with optional filtering and search",
        "parameters": [
          {
            "name": "page",
            "in": "query",
            "description": "Page number for pagination",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Number of items per page",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 10
            }
          },
          {
            "name": "companyId",
            "in": "query",
            "description": "Filter activities by company ID",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "activityOwner",
            "in": "query",
            "description": "Filter activities by owner (created by)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "key",
            "in": "query",
            "description": "Filter activities by type/key",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Filter activities by status",
            "schema": {
              "type": "integer",
              "enum": [0, 1]
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Search activities by value or key fields",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sortBy",
            "in": "query",
            "description": "Field to sort by",
            "schema": {
              "type": "string",
              "enum": ["createdAt", "updatedAt", "key", "activityOwner", "status"],
              "default": "createdAt"
            }
          },
          {
            "name": "sortOrder",
            "in": "query",
            "description": "Sort order",
            "schema": {
              "type": "string",
              "enum": ["ASC", "DESC"],
              "default": "DESC"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedActivityResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/activities/company/{companyId}": {
      "get": {
        "tags": ["Activities"],
        "summary": "Get activities by company ID",
        "description": "Retrieve activities for a specific company with pagination",
        "parameters": [
          {
            "name": "companyId",
            "in": "path",
            "required": true,
            "description": "Company ID",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaginatedActivityResponse"
                }
              }
            }
          }
        }
      }
    },
    "/activities/{id}": {
      "get": {
        "tags": ["Activities"],
        "summary": "Get activity by ID",
        "description": "Retrieve a single activity by its ID",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Activity ID",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Activity"
                }
              }
            }
          },
          "404": {
            "description": "Activity not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "tags": ["Health"],
        "summary": "Health check endpoint",
        "description": "Check if the API is running",
        "responses": {
          "200": {
            "description": "API is healthy",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "example": "ok"
                    },
                    "timestamp": {
                      "type": "string",
                      "format": "date-time"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Activity": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "example": "F7D949EB-6F14-264F-BDC5-D493732EC504"
          },
          "value": {
            "type": "string",
            "nullable": true,
            "example": "WorkOrder W574583-2 Submitted"
          },
          "key": {
            "type": "string",
            "nullable": true,
            "example": "Workorder"
          },
          "activityOwner": {
            "type": "string",
            "nullable": true,
            "example": "Quintin Driskell"
          },
          "status": {
            "type": "integer",
            "nullable": true,
            "example": 0,
            "description": "0=inactive, 1=active"
          },
          "companyId": {
            "type": "string",
            "format": "uuid",
            "nullable": true,
            "example": "677E86E4-0BBC-4E17-91B2-008B381FE1BD"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "example": "2025-06-16T15:14:00.000Z"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time",
            "example": "2025-06-16T19:33:17.000Z"
          },
          "createdBy": {
            "type": "string",
            "nullable": true,
            "example": "Quintin Driskell"
          },
          "updatedBy": {
            "type": "string",
            "nullable": true,
            "example": null
          }
        }
      },
      "PaginatedActivityResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Activity"
            }
          },
          "total": {
            "type": "integer",
            "example": 416
          },
          "page": {
            "type": "integer",
            "example": 1
          },
          "limit": {
            "type": "integer",
            "example": 10
          },
          "totalPages": {
            "type": "integer",
            "example": 42
          },
          "hasNext": {
            "type": "boolean",
            "example": true
          },
          "hasPrev": {
            "type": "boolean",
            "example": false
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "example": "Internal Server Error"
          },
          "message": {
            "type": "string",
            "example": "Failed to fetch activities"
          },
          "details": {
            "type": "string",
            "description": "Additional error details (only in development)"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Activities",
      "description": "Activity management endpoints"
    },
    {
      "name": "Health",
      "description": "Health check endpoints"
    }
  ]
}