{
  "openapi": "3.0.4",
  "info": {
    "title": "CambodiaData.Server | v1",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://testmini1.cammer.tech/"
    }
  ],
  "paths": {
    "/api/v1/geo/provinces": {
      "get": {
        "tags": [
          "Geography"
        ],
        "summary": "All capital/provinces (2-digit codes).",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/GeographyDto"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/geo/children/{parentCode}": {
      "get": {
        "tags": [
          "Geography"
        ],
        "summary": "Direct children of a place: provinces of '00', districts of a province, communes of a district.",
        "parameters": [
          {
            "name": "parentCode",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/GeographyDto"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/geo/{code}": {
      "get": {
        "tags": [
          "Geography"
        ],
        "summary": "One place with its ancestors.",
        "parameters": [
          {
            "name": "code",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GeographyDetailDto"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/indicators": {
      "get": {
        "tags": [
          "Indicators"
        ],
        "summary": "Indicator catalogue, optionally filtered by category (e.g. INFRASTRUCTURE, MONEY_BANKING, POVERTY).",
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/IndicatorDto"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/inquiry/search": {
      "post": {
        "tags": [
          "Inquiry"
        ],
        "summary": "Resolves a free-text question (English or Khmer) into places, indicators and answers.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/InquiryRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InquiryResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/metrics/query": {
      "get": {
        "tags": [
          "Metrics"
        ],
        "summary": "Time series of one indicator for up to 20 places (repeat geoCode or comma-separate; match series by geography.code). Defaults to national.",
        "parameters": [
          {
            "name": "indicatorId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "geoCode",
            "in": "query",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MetricQueryResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/metrics/ranking": {
      "get": {
        "tags": [
          "Metrics"
        ],
        "summary": "Children of a place ranked by an indicator, for a period or the latest available one.",
        "parameters": [
          {
            "name": "indicatorId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "parentCode",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "period",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RankingResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/telegram-login": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "Exchanges a Telegram Login Widget payload for a bearer token (browser sessions).",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TelegramLoginRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthTokenResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/config": {
      "get": {
        "tags": [
          "Auth"
        ],
        "summary": "Sign-in options offered by this server (bot username for t.me links, whether sign-in is required).",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthConfigDto"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/otp/start": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "Starts a web sign-in. Returns a bot deep link; the bot sends a 6-digit code when the user taps Start (or immediately to a known @username).",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OtpStartRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OtpStartResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/auth/otp/verify": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "Exchanges the bot-delivered code for a bearer token.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OtpVerifyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthTokenResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/me": {
      "get": {
        "tags": [
          "Auth"
        ],
        "summary": "The signed-in user. Mini App: 'Authorization: tma <initData>'; browser: 'Authorization: Bearer <token>'.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserDto"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/admin-auth/qr": {
      "post": {
        "tags": [
          "Admin sign-in"
        ],
        "summary": "Starts a QR sign-in. Show the QR; keep challengeId in the page. The bot sends the code to whoever scans it (admins only).",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminQrLoginResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/admin-auth/phone": {
      "post": {
        "tags": [
          "Admin sign-in"
        ],
        "summary": "Sends a code to the admin with this phone number, if they have signed in by QR before. Same answer either way.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdminPhoneLoginRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminPhoneLoginResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/admin-auth/verify": {
      "post": {
        "tags": [
          "Admin sign-in"
        ],
        "summary": "Exchanges challengeId + code for an 8-hour admin session token.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdminVerifyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminSessionResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/admin-auth/bootstrap": {
      "post": {
        "tags": [
          "Admin sign-in"
        ],
        "summary": "Creates the first admin from a phone number. Requires the bootstrap key; refused once any admin exists.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdminBootstrapRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminIdentityDto"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/admin/sync-status": {
      "get": {
        "tags": [
          "Admin"
        ],
        "summary": "Per worker: whether it is running, and each feed's last result and next scheduled run.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SyncStatusResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/admin/sync-trigger/{source}": {
      "post": {
        "tags": [
          "Admin"
        ],
        "summary": "Queues an immediate run of every feed of a source (DATA_EF, NCDD_CDB, NBC). Repeated requests coalesce.",
        "parameters": [
          {
            "name": "source",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SyncTriggerResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/admin/admins": {
      "get": {
        "tags": [
          "Admin"
        ],
        "summary": "Admins and pending invitations.",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminsOverviewResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/admin/admins/invites": {
      "post": {
        "tags": [
          "Admin"
        ],
        "summary": "Creates a single-use invite link bound to the invitee's phone. Other admins are notified.",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AdminInviteRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AdminInviteResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/admin/admins/invites/{inviteId}": {
      "delete": {
        "tags": [
          "Admin"
        ],
        "summary": "Revokes a pending invitation.",
        "parameters": [
          {
            "name": "inviteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found"
          }
        }
      }
    },
    "/api/v1/admin/admins/{identityId}/deactivate": {
      "post": {
        "tags": [
          "Admin"
        ],
        "summary": "Deactivates another admin; their sessions end immediately. The last active admin cannot be deactivated.",
        "parameters": [
          {
            "name": "identityId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int64"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AdminBootstrapRequest": {
        "required": [
          "phoneNumber",
          "fullName"
        ],
        "type": "object",
        "properties": {
          "phoneNumber": {
            "type": "string"
          },
          "fullName": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "AdminIdentityDto": {
        "required": [
          "identityId",
          "fullName",
          "phoneNumber",
          "telegramLinked",
          "isActive",
          "isMe"
        ],
        "type": "object",
        "properties": {
          "identityId": {
            "type": "integer",
            "format": "int64"
          },
          "fullName": {
            "type": "string"
          },
          "phoneNumber": {
            "type": "string"
          },
          "telegramLinked": {
            "type": "boolean"
          },
          "isActive": {
            "type": "boolean"
          },
          "isMe": {
            "type": "boolean"
          }
        }
      },
      "AdminInviteDto": {
        "required": [
          "inviteId",
          "fullName",
          "phoneNumber",
          "invitedBy",
          "opened",
          "createdAt",
          "expiresAt"
        ],
        "type": "object",
        "properties": {
          "inviteId": {
            "type": "integer",
            "format": "int64"
          },
          "fullName": {
            "type": "string"
          },
          "phoneNumber": {
            "type": "string"
          },
          "invitedBy": {
            "type": "string"
          },
          "opened": {
            "type": "boolean"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AdminInviteRequest": {
        "required": [
          "phoneNumber",
          "fullName"
        ],
        "type": "object",
        "properties": {
          "phoneNumber": {
            "type": "string"
          },
          "fullName": {
            "type": "string"
          }
        }
      },
      "AdminInviteResponse": {
        "required": [
          "inviteId",
          "inviteLink",
          "expiresAt"
        ],
        "type": "object",
        "properties": {
          "inviteId": {
            "type": "integer",
            "format": "int64"
          },
          "inviteLink": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AdminPhoneLoginRequest": {
        "required": [
          "phoneNumber"
        ],
        "type": "object",
        "properties": {
          "phoneNumber": {
            "type": "string"
          }
        }
      },
      "AdminPhoneLoginResponse": {
        "required": [
          "challengeId",
          "expiresAt"
        ],
        "type": "object",
        "properties": {
          "challengeId": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AdminQrLoginResponse": {
        "required": [
          "challengeId",
          "botLink",
          "qrSvg",
          "expiresAt"
        ],
        "type": "object",
        "properties": {
          "challengeId": {
            "type": "string"
          },
          "botLink": {
            "type": "string"
          },
          "qrSvg": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AdminSessionResponse": {
        "required": [
          "token",
          "expiresAt",
          "admin"
        ],
        "type": "object",
        "properties": {
          "token": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "admin": {
            "$ref": "#/components/schemas/AdminIdentityDto"
          }
        }
      },
      "AdminVerifyRequest": {
        "required": [
          "challengeId",
          "code"
        ],
        "type": "object",
        "properties": {
          "challengeId": {
            "type": "string"
          },
          "code": {
            "type": "string"
          }
        }
      },
      "AdminsOverviewResponse": {
        "required": [
          "admins",
          "pendingInvites"
        ],
        "type": "object",
        "properties": {
          "admins": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AdminIdentityDto"
            }
          },
          "pendingInvites": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AdminInviteDto"
            }
          }
        }
      },
      "AuthConfigDto": {
        "required": [
          "telegramEnabled",
          "botUsername",
          "requireSignIn"
        ],
        "type": "object",
        "properties": {
          "telegramEnabled": {
            "type": "boolean"
          },
          "botUsername": {
            "type": "string",
            "nullable": true
          },
          "requireSignIn": {
            "type": "boolean"
          }
        }
      },
      "AuthProvider": {
        "enum": [
          "TELEGRAM",
          "LOCAL"
        ]
      },
      "AuthTokenResponse": {
        "required": [
          "token",
          "expiresAt",
          "user"
        ],
        "type": "object",
        "properties": {
          "token": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "user": {
            "$ref": "#/components/schemas/UserDto"
          }
        }
      },
      "DataSource": {
        "enum": [
          "DATA_EF",
          "CDRI",
          "NCDD_CDB",
          "NBC",
          "CDC_ODA",
          "CDI",
          "ID_POOR"
        ]
      },
      "GeoLevel": {
        "enum": [
          "NATIONAL",
          "PROVINCE",
          "DISTRICT",
          "COMMUNE",
          "VILLAGE"
        ]
      },
      "GeographyDetailDto": {
        "required": [
          "geography",
          "ancestors"
        ],
        "type": "object",
        "properties": {
          "geography": {
            "$ref": "#/components/schemas/GeographyDto"
          },
          "ancestors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GeographyDto"
            }
          }
        }
      },
      "GeographyDto": {
        "required": [
          "code",
          "level",
          "parentCode",
          "nameEn",
          "nameKh"
        ],
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "level": {
            "$ref": "#/components/schemas/GeoLevel"
          },
          "parentCode": {
            "type": "string",
            "nullable": true
          },
          "nameEn": {
            "type": "string"
          },
          "nameKh": {
            "type": "string"
          }
        }
      },
      "GeographyMatchDto": {
        "required": [
          "geography",
          "score",
          "matchedText",
          "ancestors"
        ],
        "type": "object",
        "properties": {
          "geography": {
            "$ref": "#/components/schemas/GeographyDto"
          },
          "score": {
            "type": "number",
            "format": "double"
          },
          "matchedText": {
            "type": "string"
          },
          "ancestors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GeographyDto"
            }
          }
        }
      },
      "HttpValidationProblemDetails": {
        "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
          },
          "errors": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      },
      "IndicatorDto": {
        "required": [
          "id",
          "source",
          "nameEn",
          "nameKh",
          "unit",
          "category"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "source": {
            "$ref": "#/components/schemas/DataSource"
          },
          "nameEn": {
            "type": "string"
          },
          "nameKh": {
            "type": "string",
            "nullable": true
          },
          "unit": {
            "type": "string",
            "nullable": true
          },
          "category": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "IndicatorMatchDto": {
        "required": [
          "indicator",
          "score",
          "matchedText"
        ],
        "type": "object",
        "properties": {
          "indicator": {
            "$ref": "#/components/schemas/IndicatorDto"
          },
          "score": {
            "type": "number",
            "format": "double"
          },
          "matchedText": {
            "type": "string"
          }
        }
      },
      "InquiryAnswerDto": {
        "required": [
          "indicator",
          "geography",
          "value",
          "previous",
          "series"
        ],
        "type": "object",
        "properties": {
          "indicator": {
            "$ref": "#/components/schemas/IndicatorDto"
          },
          "geography": {
            "$ref": "#/components/schemas/GeographyDto"
          },
          "value": {
            "$ref": "#/components/schemas/MetricPointDto"
          },
          "previous": {
            "$ref": "#/components/schemas/MetricPointDto2"
          },
          "series": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MetricPointDto"
            }
          }
        }
      },
      "InquiryRequest": {
        "required": [
          "query"
        ],
        "type": "object",
        "properties": {
          "query": {
            "type": "string"
          },
          "limit": {
            "type": "integer",
            "format": "int32",
            "default": null,
            "nullable": true
          }
        }
      },
      "InquiryResponse": {
        "required": [
          "query",
          "year",
          "geographies",
          "indicators",
          "answers"
        ],
        "type": "object",
        "properties": {
          "query": {
            "type": "string"
          },
          "year": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "geographies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GeographyMatchDto"
            }
          },
          "indicators": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IndicatorMatchDto"
            }
          },
          "answers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InquiryAnswerDto"
            }
          }
        }
      },
      "MetricPointDto": {
        "required": [
          "period",
          "value",
          "text"
        ],
        "type": "object",
        "properties": {
          "period": {
            "type": "string",
            "format": "date"
          },
          "value": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "text": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "MetricPointDto2": {
        "required": [
          "period",
          "value",
          "text"
        ],
        "type": "object",
        "properties": {
          "period": {
            "type": "string",
            "format": "date"
          },
          "value": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "text": {
            "type": "string",
            "nullable": true
          }
        },
        "nullable": true
      },
      "MetricQueryResponse": {
        "required": [
          "indicator",
          "series"
        ],
        "type": "object",
        "properties": {
          "indicator": {
            "$ref": "#/components/schemas/IndicatorDto"
          },
          "series": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MetricSeriesDto"
            }
          }
        }
      },
      "MetricSeriesDto": {
        "required": [
          "geography",
          "timeGrain",
          "points"
        ],
        "type": "object",
        "properties": {
          "geography": {
            "$ref": "#/components/schemas/GeographyDto"
          },
          "timeGrain": {
            "$ref": "#/components/schemas/NullableOfTimeGrain"
          },
          "points": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MetricPointDto"
            }
          }
        }
      },
      "NullableOfSyncStatus": {
        "enum": [
          "IN_PROGRESS",
          "SUCCESS",
          "SKIPPED",
          "FAILED",
          null
        ],
        "nullable": true
      },
      "NullableOfTimeGrain": {
        "enum": [
          "YEAR",
          "QUARTER",
          "MONTH",
          "DAY",
          null
        ],
        "nullable": true
      },
      "OtpStartRequest": {
        "required": [
          "username"
        ],
        "type": "object",
        "properties": {
          "username": {
            "type": "string",
            "nullable": true
          }
        },
        "nullable": true
      },
      "OtpStartResponse": {
        "required": [
          "loginId",
          "botLink",
          "expiresAt"
        ],
        "type": "object",
        "properties": {
          "loginId": {
            "type": "string"
          },
          "botLink": {
            "type": "string"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "OtpVerifyRequest": {
        "required": [
          "loginId",
          "code"
        ],
        "type": "object",
        "properties": {
          "loginId": {
            "type": "string"
          },
          "code": {
            "type": "string"
          }
        }
      },
      "RankingEntryDto": {
        "required": [
          "rank",
          "geography",
          "value"
        ],
        "type": "object",
        "properties": {
          "rank": {
            "type": "integer",
            "format": "int32"
          },
          "geography": {
            "$ref": "#/components/schemas/GeographyDto"
          },
          "value": {
            "type": "number",
            "format": "double"
          }
        }
      },
      "RankingResponse": {
        "required": [
          "indicator",
          "parent",
          "period",
          "entries"
        ],
        "type": "object",
        "properties": {
          "indicator": {
            "$ref": "#/components/schemas/IndicatorDto"
          },
          "parent": {
            "$ref": "#/components/schemas/GeographyDto"
          },
          "period": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "entries": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RankingEntryDto"
            }
          }
        }
      },
      "SyncFeedDto": {
        "required": [
          "key",
          "status",
          "lastSyncAt",
          "recordsProcessed",
          "message",
          "nextDueAt"
        ],
        "type": "object",
        "properties": {
          "key": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/NullableOfSyncStatus"
          },
          "lastSyncAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "recordsProcessed": {
            "type": "integer",
            "format": "int32"
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "nextDueAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "SyncStatusResponse": {
        "required": [
          "generatedAt",
          "workers"
        ],
        "type": "object",
        "properties": {
          "generatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "workers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SyncWorkerDto"
            }
          }
        }
      },
      "SyncTriggerResponse": {
        "required": [
          "source",
          "alreadyRunning",
          "feeds"
        ],
        "type": "object",
        "properties": {
          "source": {
            "$ref": "#/components/schemas/DataSource"
          },
          "alreadyRunning": {
            "type": "boolean"
          },
          "feeds": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "SyncWorkerDto": {
        "required": [
          "source",
          "isRunning",
          "feeds"
        ],
        "type": "object",
        "properties": {
          "source": {
            "$ref": "#/components/schemas/DataSource"
          },
          "isRunning": {
            "type": "boolean"
          },
          "feeds": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SyncFeedDto"
            }
          }
        }
      },
      "TelegramLoginRequest": {
        "required": [
          "id",
          "first_name",
          "last_name",
          "username",
          "photo_url",
          "auth_date",
          "hash"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "integer",
            "format": "int64"
          },
          "first_name": {
            "type": "string",
            "nullable": true
          },
          "last_name": {
            "type": "string",
            "nullable": true
          },
          "username": {
            "type": "string",
            "nullable": true
          },
          "photo_url": {
            "type": "string",
            "nullable": true
          },
          "auth_date": {
            "type": "integer",
            "format": "int64"
          },
          "hash": {
            "type": "string"
          }
        }
      },
      "UserDto": {
        "required": [
          "userId",
          "authProvider",
          "username",
          "firstName",
          "role"
        ],
        "type": "object",
        "properties": {
          "userId": {
            "type": "string"
          },
          "authProvider": {
            "$ref": "#/components/schemas/AuthProvider"
          },
          "username": {
            "type": "string",
            "nullable": true
          },
          "firstName": {
            "type": "string",
            "nullable": true
          },
          "role": {
            "$ref": "#/components/schemas/UserRole"
          }
        }
      },
      "UserRole": {
        "enum": [
          "USER",
          "ADMIN"
        ]
      }
    }
  },
  "tags": [
    {
      "name": "Geography"
    },
    {
      "name": "Indicators"
    },
    {
      "name": "Inquiry"
    },
    {
      "name": "Metrics"
    },
    {
      "name": "Auth"
    },
    {
      "name": "Admin sign-in"
    },
    {
      "name": "Admin"
    }
  ]
}