{
  "openapi": "3.1.1",
  "info": {
    "title": "RouteManReports.App | v1",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "http://reports.routevia.com/"
    }
  ],
  "paths": {
    "/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/reports": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Catalogue of standard Crystal reports with runnable flag",
        "operationId": "ListReports",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AnonymousTypeOfstringAndstringAndlongAndstringAndbooleanAndIReadOnlyListOfstringAndReportParameterInfo"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/reports/{id}": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Report detail including SQL parameter names when known",
        "operationId": "GetReport",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "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/reports/{id}/html": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Execute report and return HTML table",
        "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 and return PDF",
        "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"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AnonymousTypeOfstringAndstringAndlongAndstringAndbooleanAndIReadOnlyListOfstringAndReportParameterInfo": {
        "required": [
          "id",
          "fileName",
          "sizeBytes",
          "sourceKind",
          "runnable",
          "sqlParameters",
          "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"
            }
          },
          "parameters": {
            "$ref": "#/components/schemas/ReportParameterInfo"
          }
        }
      },
      "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"
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Program"
    },
    {
      "name": "Reports"
    }
  ]
}