{
  "openapi": "3.1.1",
  "info": {
    "title": "RouteManReports.App | v1",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://reports-staging.routevia.com/"
    }
  ],
  "paths": {
    "/api/auth/me": {
      "get": {
        "tags": [
          "RouteManReports.App"
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/login": {
      "get": {
        "tags": [
          "RouteManReports.App"
        ],
        "parameters": [
          {
            "name": "returnUrl",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/_diag/auth-runtime": {
      "get": {
        "tags": [
          "RouteManReports.App"
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/Account/Login": {
      "get": {
        "tags": [
          "RouteManReports.App"
        ],
        "parameters": [
          {
            "name": "returnUrl",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/Account/Logout": {
      "get": {
        "tags": [
          "RouteManReports.App"
        ],
        "parameters": [
          {
            "name": "returnUrl",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/reports/{id}": {
      "get": {
        "tags": [
          "Program"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "rmid",
            "in": "query",
            "required": true,
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/reports/{id}/pdf": {
      "get": {
        "tags": [
          "Program"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "rmid",
            "in": "query",
            "required": true,
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/tenants": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Active RMIDs from RouteManConfiguration.RouteManCustomers",
        "operationId": "ListTenants",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/tenants/{rmid}/ping": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Resolve RMID → Connectionstring5 and open tenant DB",
        "operationId": "PingTenant",
        "parameters": [
          {
            "name": "rmid",
            "in": "path",
            "required": true,
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/tenants/{rmid}/menu": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Desktop-like report tree from tenant Menues + Reports (custom)",
        "operationId": "GetTenantMenu",
        "parameters": [
          {
            "name": "rmid",
            "in": "path",
            "required": true,
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/tenants/{rmid}/host": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "SystemData / BillFromInfo company header + logo availability",
        "operationId": "GetTenantHost",
        "parameters": [
          {
            "name": "rmid",
            "in": "path",
            "required": true,
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/tenants/{rmid}/lookups/{table}": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "LoadDropDownList-style tenant lookup (allowlisted tables/columns)",
        "operationId": "TenantLookup",
        "parameters": [
          {
            "name": "rmid",
            "in": "path",
            "required": true,
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "table",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "display",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "value",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/reports": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Static extracted catalogue (fallback); prefer /api/tenants/{rmid}/menu",
        "operationId": "ListReports",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AnonymousTypeOfstringAndstringAndlongAndstringAndbooleanAndIReadOnlyListOfstringAndIReadOnlyListOfReportInputInfoAndReportParameterInfo"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/reports/{id}": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Report detail including legacy parameter schema",
        "operationId": "GetReport",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/reports/{id}/parameters": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Legacy Parameters.aspx-shaped schema + Crystal inputs",
        "operationId": "GetReportParameters",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/reports/{id}/html": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Execute report HTML with tenant logo/header chrome",
        "operationId": "RunReportHtml",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "rmid",
            "in": "query",
            "required": true,
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    },
    "/api/reports/{id}/pdf": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Execute report PDF with tenant logo/header chrome",
        "operationId": "RunReportPdf",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "rmid",
            "in": "query",
            "required": true,
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "tags": [
          "Reports"
        ],
        "summary": "Execute report PDF with rmid and parameters in the JSON body",
        "operationId": "RunReportPdfFromBody",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RunReportBody"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AnonymousTypeOfstringAndstringAndlongAndstringAndbooleanAndIReadOnlyListOfstringAndIReadOnlyListOfReportInputInfoAndReportParameterInfo": {
        "required": [
          "id",
          "fileName",
          "sizeBytes",
          "sourceKind",
          "runnable",
          "sqlParameters",
          "inputs",
          "parameters"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": [
              "null",
              "string"
            ]
          },
          "fileName": {
            "type": [
              "null",
              "string"
            ]
          },
          "sizeBytes": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int64"
          },
          "sourceKind": {
            "type": [
              "null",
              "string"
            ]
          },
          "runnable": {
            "type": "boolean"
          },
          "sqlParameters": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "type": "string"
            }
          },
          "inputs": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "$ref": "#/components/schemas/ReportInputInfo"
            }
          },
          "parameters": {
            "$ref": "#/components/schemas/ReportParameterInfo"
          }
        }
      },
      "ReportInputInfo": {
        "required": [
          "name",
          "inputType",
          "source"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "inputType": {
            "type": "string"
          },
          "source": {
            "type": "string"
          }
        }
      },
      "ReportParameterInfo": {
        "required": [
          "id",
          "comment",
          "usesDateRange",
          "usesCustomer",
          "usesRoute",
          "usesProduct"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "comment": {
            "type": "string"
          },
          "usesDateRange": {
            "type": "boolean"
          },
          "usesCustomer": {
            "type": "boolean"
          },
          "usesRoute": {
            "type": "boolean"
          },
          "usesProduct": {
            "type": "boolean"
          }
        }
      },
      "RunReportBody": {
        "required": [
          "rmid",
          "parameters"
        ],
        "type": "object",
        "properties": {
          "rmid": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "integer",
              "string"
            ],
            "format": "int32"
          },
          "parameters": {
            "type": [
              "null",
              "object"
            ]
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "RouteManReports.App"
    },
    {
      "name": "Program"
    },
    {
      "name": "Reports"
    }
  ]
}