{
  "openapi": "3.1.0",
  "info": {
    "title": "JailScope Public API",
    "version": "1.0.0",
    "description": "Public read-only endpoints for discovering county jail roster pages and retrieving source-reported roster snapshots."
  },
  "servers": [
    {
      "url": "https://jailscope.com"
    }
  ],
  "paths": {
    "/api/health": {
      "get": {
        "operationId": "getApiHealth",
        "summary": "Check API publication status",
        "responses": {
          "200": {
            "description": "API status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/api/jails": {
      "get": {
        "operationId": "listJails",
        "summary": "List county jail roster pages",
        "responses": {
          "200": {
            "description": "Jail directory index",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JailIndex"
                }
              }
            }
          }
        }
      }
    },
    "/api/jails/{slug}": {
      "get": {
        "operationId": "getJailRoster",
        "summary": "Get a county jail roster snapshot",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The jail slug from the index response."
          }
        ],
        "responses": {
          "200": {
            "description": "Jail roster snapshot",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JailRoster"
                }
              }
            }
          },
          "404": {
            "description": "Jail slug not found"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "JailIndex": {
        "type": "object",
        "properties": {
          "totals": {
            "type": "object"
          },
          "jails": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/JailSummary"
            }
          }
        }
      },
      "JailSummary": {
        "type": "object",
        "properties": {
          "slug": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "county": {
            "type": "string"
          },
          "state": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "source_type": {
            "type": "string"
          },
          "coverage_scope": {
            "type": "string",
            "description": "Verified source coverage scope, such as current_population."
          },
          "source_url": {
            "type": "string",
            "format": "uri"
          },
          "last_success_at": {
            "type": "string",
            "format": "date-time"
          },
          "active_count": {
            "type": "integer"
          },
          "page_path": {
            "type": "string"
          }
        }
      },
      "JailRoster": {
        "type": "object",
        "properties": {
          "jail": {
            "type": "object"
          },
          "stats": {
            "type": "object"
          },
          "contact": {
            "type": "object"
          },
          "operations": {
            "type": "object"
          },
          "source": {
            "type": "object",
            "description": "Provenance and freshness context for the published snapshot.",
            "properties": {
              "url": {
                "type": "string",
                "format": "uri"
              },
              "type": {
                "type": "string"
              },
              "coverage_scope": {
                "type": "string",
                "description": "Verified source coverage scope, such as current_population."
              },
              "last_success_at": {
                "type": "string",
                "format": "date-time"
              },
              "status": {
                "type": "string"
              }
            }
          },
          "inmates": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      }
    }
  }
}