{
  "openapi": "3.0.1",
  "info": {
    "title": "WebAPI-C26",
    "description": "API for executing SQL queries and stored procedures with JWT authentication",
    "version": "v1"
  },
  "paths": {
    "/api/Auth/login": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "Authenticate user and get JWT token",
        "requestBody": {
          "description": "Username and password",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AuthRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/AuthRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/AuthRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/Baseline/databases": {
      "get": {
        "tags": [
          "Baseline"
        ],
        "summary": "Retrieves list of all databases with 'ihp' prefix (excluding 'ihplic') that the authenticated user has access to.",
        "description": "Uses dynamic database discovery from SQL Server. Returns filtered list based on user's AllowedDatabases claim.\r\nRequires authentication via JWT token.",
        "responses": {
          "200": {
            "description": "Returns the list of accessible databases",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/DatabaseListResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DatabaseListResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/DatabaseListResponse"
                }
              }
            }
          },
          "400": {
            "description": "Dynamic database discovery is not enabled",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "User is not authenticated",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error occurred"
          }
        }
      }
    },
    "/api/Baseline/users": {
      "post": {
        "tags": [
          "Baseline"
        ],
        "summary": "Retrieves list of all users from the Users table in a specific database.",
        "description": "Requires authentication and database access authorization.\r\nReturns user ID and username for all users in the specified database.",
        "requestBody": {
          "description": "Request containing the database name",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UsersListRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/UsersListRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/UsersListRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returns the list of users",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/UsersListResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsersListResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsersListResponse"
                }
              }
            }
          },
          "400": {
            "description": "Database name is missing or invalid",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "User is not authenticated",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "User does not have access to the specified database",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "Database error or internal server error"
          }
        }
      }
    },
    "/api/Baseline/premises": {
      "post": {
        "tags": [
          "Baseline"
        ],
        "summary": "Retrieves list of premises allocated to a specific user based on their UserPermissions.",
        "description": "Queries premises that the user has access to through the UserPermissions and PremPrTy tables.\r\nReturns premises ID, code, and name. Requires authentication and database access authorization.",
        "requestBody": {
          "description": "Request containing database name and user ID",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PremisesListRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/PremisesListRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/PremisesListRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returns the list of premises for the user",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/PremisesListResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PremisesListResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/PremisesListResponse"
                }
              }
            }
          },
          "400": {
            "description": "Database name is missing or invalid",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "User is not authenticated",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "User does not have access to the specified database",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "Database error or internal server error"
          }
        }
      }
    },
    "/api/Baseline/all-premises": {
      "post": {
        "tags": [
          "Baseline"
        ],
        "summary": "Retrieves complete list of all premises in a specific database, regardless of user permissions.",
        "description": "Returns all premises from the Premises table with ID, code, and name.\r\nUseful for administrative queries or database-wide operations.\r\nRequires authentication and database access authorization.",
        "requestBody": {
          "description": "Request containing the database name",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AllPremisesRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/AllPremisesRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/AllPremisesRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returns the complete list of premises",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/AllPremisesResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AllPremisesResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/AllPremisesResponse"
                }
              }
            }
          },
          "400": {
            "description": "Database name is missing or invalid",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "User is not authenticated",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "User does not have access to the specified database",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "Database error or internal server error"
          }
        }
      }
    },
    "/api/Database/available-databases": {
      "get": {
        "tags": [
          "Database"
        ],
        "summary": "Retrieves list of all available databases matching the configured prefix from SQL Server.",
        "description": "Returns unfiltered list of databases. Use /api/baseline/databases for user-filtered results.\r\nRequires authentication via JWT token.",
        "responses": {
          "200": {
            "description": "Returns the list of available databases",
            "content": {
              "text/plain": {
                "schema": { }
              },
              "application/json": {
                "schema": { }
              },
              "text/json": {
                "schema": { }
              }
            }
          },
          "400": {
            "description": "Dynamic database discovery is disabled or error occurred",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "User is not authenticated",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/Database/execute-query": {
      "post": {
        "tags": [
          "Database"
        ],
        "summary": "Executes an ad-hoc SQL query against a specified database and returns results as JSON.",
        "description": "Accepts any valid SQL query (SELECT, INSERT, UPDATE, DELETE, etc.).\r\nResults are returned as an array of objects with dynamic properties based on query columns.\r\nRequires authentication and database access authorization. Use with caution.",
        "requestBody": {
          "description": "Request containing database name and SQL query string",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SqlQueryRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/SqlQueryRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/SqlQueryRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Query executed successfully with results",
            "content": {
              "text/plain": {
                "schema": { }
              },
              "application/json": {
                "schema": { }
              },
              "text/json": {
                "schema": { }
              }
            }
          },
          "400": {
            "description": "Invalid request or query execution failed",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "User is not authenticated",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "User does not have access to the specified database",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/Database/execute-stored-procedure": {
      "post": {
        "tags": [
          "Database"
        ],
        "summary": "Executes a named stored procedure with optional parameters and returns results as JSON.",
        "description": "Accepts stored procedure name and dictionary of parameters.\r\nResults are returned as an array of objects with dynamic properties.\r\nRequires authentication and database access authorization.",
        "requestBody": {
          "description": "Request containing database name, stored procedure name, and parameters dictionary",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/StoredProcRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/StoredProcRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/StoredProcRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Stored procedure executed successfully",
            "content": {
              "text/plain": {
                "schema": { }
              },
              "application/json": {
                "schema": { }
              },
              "text/json": {
                "schema": { }
              }
            }
          },
          "400": {
            "description": "Invalid request or procedure execution failed",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "User is not authenticated",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "User does not have access to the specified database",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/Database/validate-user": {
      "post": {
        "tags": [
          "Database"
        ],
        "summary": "Validates user credentials against database using sp_ValidateUser stored procedure.",
        "description": "Calls sp_ValidateUser with username (encrypted SHA1), password (encrypted), and premises (Code or Name).\r\nReturns validation result with IsValid flag and message.\r\nRequires authentication and database access authorization.",
        "requestBody": {
          "description": "Request containing database name, username, encrypted password, and premises identifier",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UserValidationRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/UserValidationRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/UserValidationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "User validation successful",
            "content": {
              "text/plain": {
                "schema": { }
              },
              "application/json": {
                "schema": { }
              },
              "text/json": {
                "schema": { }
              }
            }
          },
          "400": {
            "description": "Invalid request or missing required fields",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "User validation failed or not authenticated",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "User does not have access to the specified database",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/JKPI/get-johneskpi-indprem": {
      "post": {
        "tags": [
          "JKPI"
        ],
        "summary": "Retrieves Johnes disease KPI data for a single premises over a specified date range.",
        "description": "Calls stored procedure: kcIH_WebAPI_Ind_JDKPI\r\nIncludes optional parameters for cows tested threshold, survival days, test counts, and period.\r\nMay take several minutes for large datasets. Timeout: 30 minutes.\r\nRequires authentication and database access authorization.",
        "requestBody": {
          "description": "Request with databaseName, userId, premisesId, startDate, endDate, and optional filter parameters",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KpiRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/KpiRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/KpiRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "KPI data retrieved successfully",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/KpiResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters or date range",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "User is not authenticated",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "User does not have access to the specified database",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Database not found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "Database error or internal server error"
          }
        }
      }
    },
    "/api/JKPI/get-johneskpi-user": {
      "post": {
        "tags": [
          "JKPI"
        ],
        "summary": "Retrieves Johnes disease KPI data for all premises accessible to a specific user.",
        "description": "Calls stored procedure: kcIH_WebAPI_User_JDKPI\r\nReturns aggregated data for all premises the user has access to through UserPermissions.\r\nIncludes optional parameters for cows tested threshold, survival days, test counts, and period.\r\nMay take several minutes for users with many premises. Timeout: 30 minutes.\r\nRequires authentication and database access authorization.",
        "requestBody": {
          "description": "Request with databaseName, userId, startDate, endDate, and optional filter parameters (no premisesId)",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KpiRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/KpiRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/KpiRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "KPI data retrieved successfully",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/KpiResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters or date range",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "User is not authenticated",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "User does not have access to the specified database",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Database not found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "Database error or internal server error"
          }
        }
      }
    },
    "/api/JKPI/get-johneskpi-db": {
      "post": {
        "tags": [
          "JKPI"
        ],
        "summary": "Retrieves Johnes disease KPI data for all premises in the entire database.",
        "description": "Calls stored procedure: kcIH_WebAPI_DB_JDKPI\r\nReturns data for every premises in the database, regardless of user permissions.\r\nIncludes optional parameters for cows tested threshold, survival days, test counts, and period.\r\nMay take several minutes for databases with many premises. Timeout: 30 minutes.\r\nRequires authentication and database access authorization.",
        "requestBody": {
          "description": "Request with databaseName, startDate, endDate, and optional filter parameters (no userId or premisesId)",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KpiRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/KpiRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/KpiRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "KPI data retrieved successfully",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/KpiResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters or date range",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "User is not authenticated",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "User does not have access to the specified database",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Database not found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "Database error or internal server error"
          }
        }
      }
    },
    "/api/JKPI/get-johnes-annualmonitor-db": {
      "post": {
        "tags": [
          "JKPI"
        ],
        "summary": "Retrieves Johnes disease annual monitoring summary data for a specified date range.",
        "description": "Calls stored procedure: kcIH_WebAPI_DB_JohnesSum\r\nReturns annual monitoring summary data across all premises for the specified user.\r\nMay take several minutes for large datasets. Timeout: 30 minutes.\r\nRequires authentication and database access authorization.",
        "requestBody": {
          "description": "Request with databaseName, startDate, endDate, and optional parameters (userId, cowsTested, survivalDays, numberTested1, numberTested2)",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnnualMonitorRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/AnnualMonitorRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/AnnualMonitorRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Annual monitor data retrieved successfully",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/KpiResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters or date range",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "User is not authenticated",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "User does not have access to the specified database",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Database not found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "Database error or internal server error"
          }
        }
      }
    },
    "/api/JKPI/get-johnes-annualmonitor-user": {
      "post": {
        "tags": [
          "JKPI"
        ],
        "summary": "Retrieves Johnes disease annual monitoring summary data for a specific user across all their premises.",
        "description": "Calls stored procedure: kcIH_WebAPI_User_JohnesSum\r\nReturns annual monitoring summary data for all premises allowed for the specified user.\r\nMay take several minutes for large datasets. Timeout: 30 minutes.\r\nRequires authentication and database access authorization.",
        "requestBody": {
          "description": "Request with databaseName, userId, startDate, endDate, and optional parameters (cowsTested, survivalDays, numberTested1, numberTested2)",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnnualMonitorUserRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/AnnualMonitorUserRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/AnnualMonitorUserRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Annual monitor data retrieved successfully",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/KpiResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters or date range",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "User is not authenticated",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "User does not have access to the specified database",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Database not found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "Database error or internal server error"
          }
        }
      }
    },
    "/api/JKPI/get-johnes-annualmonitor-indprem": {
      "post": {
        "tags": [
          "JKPI"
        ],
        "summary": "Retrieves Johnes disease annual monitoring summary data for a specific premise allowed for a user.",
        "description": "Calls stored procedure: kcIH_WebAPI_Ind_JohnesSum\r\nReturns annual monitoring summary data for an individual premise accessible by the specified user.\r\nMay take several minutes for large datasets. Timeout: 30 minutes.\r\nRequires authentication and database access authorization.",
        "requestBody": {
          "description": "Request with databaseName, userId, premisesId, startDate, endDate, and optional parameters (cowsTested, survivalDays, numberTested1, numberTested2)",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnnualMonitorIndividualPremiseRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/AnnualMonitorIndividualPremiseRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/AnnualMonitorIndividualPremiseRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Annual monitor data retrieved successfully",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/KpiResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters or date range",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "User is not authenticated",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "User does not have access to the specified database",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Database not found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "Database error or internal server error"
          }
        }
      }
    },
    "/api/KPI/get-kpi-indprem": {
      "post": {
        "tags": [
          "KPI"
        ],
        "summary": "Retrieves standard KPI data for a single premises at a specific reference date.",
        "description": "Calls stored procedure: kcIH_WebAPI_Ind_KPI\r\nReturns standard KPI metrics (not Johnes-specific) for the specified premises.\r\nMay take several minutes for large datasets. Timeout: 30 minutes.\r\nRequires authentication and database access authorization.",
        "requestBody": {
          "description": "Request with databaseName, userId, premisesId, and referenceDate",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KpiStandardRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/KpiStandardRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/KpiStandardRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "KPI data retrieved successfully",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/KpiStandardResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiStandardResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiStandardResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "User is not authenticated",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "User does not have access to the specified database",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Database not found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "Database error or internal server error"
          }
        }
      }
    },
    "/api/KPI/get-kpi-db": {
      "post": {
        "tags": [
          "KPI"
        ],
        "summary": "Retrieves standard KPI data for all premises in the entire database.",
        "description": "Calls stored procedure: kcIH_WebAPI_DB_KPI\r\nReturns standard KPI metrics for every premises in the database, regardless of user permissions.\r\nUses userId parameter (defaults to 1 if not provided) as required by stored procedure.\r\nMay take several minutes for databases with many premises. Timeout: 30 minutes.\r\nRequires authentication and database access authorization.",
        "requestBody": {
          "description": "Request with databaseName, userId (optional, defaults to 1), and referenceDate",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KpiStandardRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/KpiStandardRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/KpiStandardRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "KPI data retrieved successfully",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/KpiStandardResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiStandardResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiStandardResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "User is not authenticated",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "User does not have access to the specified database",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Database not found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "Database error or internal server error"
          }
        }
      }
    },
    "/api/KPI/get-kpi-user": {
      "post": {
        "tags": [
          "KPI"
        ],
        "summary": "Retrieves standard KPI data for all premises accessible to a specific user.",
        "description": "Calls stored procedure: kcIH_WebAPI_User_KPI\r\nReturns standard KPI metrics for all premises the user has access to through UserPermissions.\r\nMay take several minutes for users with many premises. Timeout: 30 minutes.\r\nRequires authentication and database access authorization.",
        "requestBody": {
          "description": "Request with databaseName, userId, and referenceDate",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/KpiStandardRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/KpiStandardRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/KpiStandardRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "KPI data retrieved successfully",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/KpiStandardResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiStandardResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/KpiStandardResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "401": {
            "description": "User is not authenticated",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "403": {
            "description": "User does not have access to the specified database",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "404": {
            "description": "Database not found",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "500": {
            "description": "Database error or internal server error"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AllPremisesRequest": {
        "type": "object",
        "properties": {
          "databaseName": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "AllPremisesResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "premises": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PremisesInfo"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "AnnualMonitorIndividualPremiseRequest": {
        "type": "object",
        "properties": {
          "databaseName": {
            "type": "string",
            "nullable": true
          },
          "userId": {
            "type": "integer",
            "format": "int32"
          },
          "premisesId": {
            "type": "integer",
            "format": "int32"
          },
          "startDate": {
            "type": "string",
            "format": "date-time"
          },
          "endDate": {
            "type": "string",
            "format": "date-time"
          },
          "cowsTested": {
            "type": "number",
            "format": "double"
          },
          "survivalDays": {
            "type": "integer",
            "format": "int32"
          },
          "numberTested1": {
            "type": "integer",
            "format": "int32"
          },
          "numberTested2": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "AnnualMonitorRequest": {
        "type": "object",
        "properties": {
          "databaseName": {
            "type": "string",
            "nullable": true
          },
          "startDate": {
            "type": "string",
            "format": "date-time"
          },
          "endDate": {
            "type": "string",
            "format": "date-time"
          },
          "userId": {
            "type": "integer",
            "format": "int32"
          },
          "cowsTested": {
            "type": "number",
            "format": "double"
          },
          "survivalDays": {
            "type": "integer",
            "format": "int32"
          },
          "numberTested1": {
            "type": "integer",
            "format": "int32"
          },
          "numberTested2": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "AnnualMonitorUserRequest": {
        "type": "object",
        "properties": {
          "databaseName": {
            "type": "string",
            "nullable": true
          },
          "userId": {
            "type": "integer",
            "format": "int32"
          },
          "startDate": {
            "type": "string",
            "format": "date-time"
          },
          "endDate": {
            "type": "string",
            "format": "date-time"
          },
          "cowsTested": {
            "type": "number",
            "format": "double"
          },
          "survivalDays": {
            "type": "integer",
            "format": "int32"
          },
          "numberTested1": {
            "type": "integer",
            "format": "int32"
          },
          "numberTested2": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "AuthRequest": {
        "type": "object",
        "properties": {
          "username": {
            "type": "string",
            "nullable": true
          },
          "password": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "AuthResponse": {
        "type": "object",
        "properties": {
          "token": {
            "type": "string",
            "nullable": true
          },
          "expiration": {
            "type": "string",
            "format": "date-time"
          },
          "username": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "DatabaseListResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "databases": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "KpiRequest": {
        "type": "object",
        "properties": {
          "databaseName": {
            "type": "string",
            "nullable": true
          },
          "userId": {
            "type": "integer",
            "format": "int32"
          },
          "premisesId": {
            "type": "integer",
            "format": "int32"
          },
          "startDate": {
            "type": "string",
            "format": "date-time"
          },
          "endDate": {
            "type": "string",
            "format": "date-time"
          },
          "cowsTested": {
            "type": "number",
            "format": "double"
          },
          "survivalDays": {
            "type": "integer",
            "format": "int32"
          },
          "numberTested1": {
            "type": "integer",
            "format": "int32"
          },
          "numberTested2": {
            "type": "integer",
            "format": "int32"
          },
          "period": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "KpiResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": { }
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "KpiStandardRequest": {
        "type": "object",
        "properties": {
          "databaseName": {
            "type": "string",
            "nullable": true
          },
          "userId": {
            "type": "integer",
            "format": "int32"
          },
          "referenceDate": {
            "type": "string",
            "format": "date-time"
          },
          "premisesId": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "KpiStandardResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": { }
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PremisesInfo": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "code": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "PremisesListRequest": {
        "type": "object",
        "properties": {
          "databaseName": {
            "type": "string",
            "nullable": true
          },
          "userId": {
            "type": "integer",
            "format": "int32"
          }
        },
        "additionalProperties": false
      },
      "PremisesListResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "premises": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PremisesInfo"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": { }
      },
      "SqlQueryRequest": {
        "type": "object",
        "properties": {
          "databaseName": {
            "type": "string",
            "nullable": true
          },
          "query": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "StoredProcRequest": {
        "type": "object",
        "properties": {
          "databaseName": {
            "type": "string",
            "nullable": true
          },
          "procedureName": {
            "type": "string",
            "nullable": true
          },
          "parameters": {
            "type": "object",
            "additionalProperties": { },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UserInfo": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int32"
          },
          "user": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UserValidationRequest": {
        "type": "object",
        "properties": {
          "databaseName": {
            "type": "string",
            "nullable": true
          },
          "username": {
            "type": "string",
            "nullable": true
          },
          "userPassword": {
            "type": "string",
            "nullable": true
          },
          "premises": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UsersListRequest": {
        "type": "object",
        "properties": {
          "databaseName": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "UsersListResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "users": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UserInfo"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      }
    },
    "securitySchemes": {
      "Bearer": {
        "type": "apiKey",
        "description": "JWT Authorization header using the Bearer scheme. Enter 'Bearer' [space] and then your token in the text input below.",
        "name": "Authorization",
        "in": "header"
      }
    }
  },
  "security": [
    {
      "Bearer": [ ]
    }
  ]
}