{
    "openapi": "3.0.0",
    "info": {
        "title": "Nigeria Electoral Data API",
        "version": "1.0.0"
    },
    "paths": {
        "/api/v1/summary": {
            "get": {
                "tags": [
                    "Summary"
                ],
                "summary": "Get overall electoral data summary.",
                "description": "Returns total counts for states, LGAs, wards, and polling units across Nigeria.",
                "operationId": "get_api_v1_summary",
                "responses": {
                    "200": {
                        "description": "Summary statistics returned successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "example": "success"
                                        },
                                        "data": {
                                            "properties": {
                                                "stateCount": {
                                                    "type": "integer",
                                                    "example": 37
                                                },
                                                "lgaCount": {
                                                    "type": "integer",
                                                    "example": 774
                                                },
                                                "wardCount": {
                                                    "type": "integer",
                                                    "example": 8809
                                                },
                                                "pollingUnitCount": {
                                                    "type": "integer",
                                                    "example": 176846
                                                }
                                            },
                                            "type": "object"
                                        },
                                        "timestamp": {
                                            "type": "string",
                                            "format": "date-time"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/v1/states": {
            "get": {
                "tags": [
                    "States"
                ],
                "summary": "List all states.",
                "description": "Returns all Nigerian states with their electoral statistics. Supports pagination.",
                "operationId": "get_api_v1_states_index",
                "parameters": [
                    {
                        "name": "page",
                        "in": "query",
                        "description": "Page number",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 1,
                            "minimum": 1
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "description": "Results per page",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 50,
                            "maximum": 100,
                            "minimum": 1
                        }
                    },
                    {
                        "name": "active",
                        "in": "query",
                        "description": "Filter by active",
                        "required": false,
                        "schema": {
                            "type": "boolean"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "List of states returned successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "example": "success"
                                        },
                                        "data": {
                                            "properties": {
                                                "states": {
                                                    "type": "array",
                                                    "items": {
                                                        "$ref": "#/components/schemas/StateListItem"
                                                    }
                                                },
                                                "total": {
                                                    "type": "integer",
                                                    "example": 37
                                                },
                                                "page": {
                                                    "type": "integer",
                                                    "example": 1
                                                },
                                                "limit": {
                                                    "type": "integer",
                                                    "example": 50
                                                },
                                                "pages": {
                                                    "type": "integer",
                                                    "example": 1
                                                }
                                            },
                                            "type": "object"
                                        },
                                        "timestamp": {
                                            "type": "string",
                                            "format": "date-time"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Not found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorResponse"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/v1/states/{id}": {
            "get": {
                "tags": [
                    "States"
                ],
                "summary": "Get a single state.",
                "description": "Returns detailed information about a specific state including LGA, ward and polling unit counts.",
                "operationId": "get_api_v1_states_show",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "State UUID",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "State details returned successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "example": "success"
                                        },
                                        "data": {
                                            "$ref": "#/components/schemas/StateDetail"
                                        },
                                        "timestamp": {
                                            "type": "string",
                                            "format": "date-time"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "State not found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorResponse"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/v1/states/{stateId}/lgas": {
            "get": {
                "tags": [
                    "LGAs"
                ],
                "summary": "List LGAs in a state.",
                "description": "Returns all Local Government Areas within a given state.",
                "operationId": "get_api_v1_lgas_index",
                "parameters": [
                    {
                        "name": "stateId",
                        "in": "path",
                        "description": "State UUID",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "description": "Page number",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 1
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "description": "Results per page",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 50,
                            "maximum": 100
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "LGA list returned successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "example": "success"
                                        },
                                        "data": {
                                            "properties": {
                                                "state": {
                                                    "$ref": "#/components/schemas/StateListItem"
                                                },
                                                "lgas": {
                                                    "type": "array",
                                                    "items": {
                                                        "$ref": "#/components/schemas/LgaListItem"
                                                    }
                                                },
                                                "total": {
                                                    "type": "integer"
                                                },
                                                "page": {
                                                    "type": "integer"
                                                },
                                                "limit": {
                                                    "type": "integer"
                                                },
                                                "pages": {
                                                    "type": "integer"
                                                }
                                            },
                                            "type": "object"
                                        },
                                        "timestamp": {
                                            "type": "string",
                                            "format": "date-time"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "State not found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorResponse"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/v1/states/{stateId}/lgas/{lgaId}": {
            "get": {
                "tags": [
                    "LGAs"
                ],
                "summary": "Get a single LGA.",
                "description": "Returns detailed information about a specific Local Government Area.",
                "operationId": "get_api_v1_lgas_show",
                "parameters": [
                    {
                        "name": "stateId",
                        "in": "path",
                        "description": "State UUID",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "lgaId",
                        "in": "path",
                        "description": "LGA UUID",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "LGA details returned successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "example": "success"
                                        },
                                        "data": {
                                            "$ref": "#/components/schemas/LgaDetail"
                                        },
                                        "timestamp": {
                                            "type": "string",
                                            "format": "date-time"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "State or LGA not found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorResponse"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/v1/states/{stateId}/lgas/{lgaId}/wards": {
            "get": {
                "tags": [
                    "Wards"
                ],
                "summary": "List wards in an LGA.",
                "description": "Returns all electoral wards within a specific Local Government Area.",
                "operationId": "get_api_v1_wards_index",
                "parameters": [
                    {
                        "name": "stateId",
                        "in": "path",
                        "description": "State UUID",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "lgaId",
                        "in": "path",
                        "description": "LGA UUID",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "description": "Page number",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 1
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "description": "Results per page",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 50,
                            "maximum": 100
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Ward list returned successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "example": "success"
                                        },
                                        "data": {
                                            "properties": {
                                                "state": {
                                                    "$ref": "#/components/schemas/StateListItem"
                                                },
                                                "lga": {
                                                    "$ref": "#/components/schemas/LgaListItem"
                                                },
                                                "wards": {
                                                    "type": "array",
                                                    "items": {
                                                        "$ref": "#/components/schemas/WardListItem"
                                                    }
                                                },
                                                "total": {
                                                    "type": "integer"
                                                },
                                                "page": {
                                                    "type": "integer"
                                                },
                                                "limit": {
                                                    "type": "integer"
                                                },
                                                "pages": {
                                                    "type": "integer"
                                                }
                                            },
                                            "type": "object"
                                        },
                                        "timestamp": {
                                            "type": "string",
                                            "format": "date-time"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "State or LGA not found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorResponse"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/v1/states/{stateId}/lgas/{lgaId}/wards/{wardId}": {
            "get": {
                "tags": [
                    "Wards"
                ],
                "summary": "Get a single ward.",
                "description": "Returns detailed information about a specific electoral ward including all polling units.",
                "operationId": "get_api_v1_wards_show",
                "parameters": [
                    {
                        "name": "stateId",
                        "in": "path",
                        "description": "State UUID",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "lgaId",
                        "in": "path",
                        "description": "LGA UUID",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "wardId",
                        "in": "path",
                        "description": "Ward UUID",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Ward details returned successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "example": "success"
                                        },
                                        "data": {
                                            "$ref": "#/components/schemas/WardDetail"
                                        },
                                        "timestamp": {
                                            "type": "string",
                                            "format": "date-time"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "State, LGA or Ward not found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorResponse"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/api/v1/states/{stateId}/lgas/{lgaId}/wards/{wardId}/polling-units": {
            "get": {
                "tags": [
                    "Polling Units"
                ],
                "summary": "List polling units in a ward.",
                "description": "Returns all polling units within a specific ward. Supports pagination.",
                "operationId": "get_api_v1_polling_units_index",
                "parameters": [
                    {
                        "name": "stateId",
                        "in": "path",
                        "description": "State UUID",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "lgaId",
                        "in": "path",
                        "description": "LGA UUID",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "wardId",
                        "in": "path",
                        "description": "Ward UUID",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "format": "uuid"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "description": "Page number",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 1
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "description": "Results per page",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "default": 50,
                            "maximum": 100
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Polling units returned successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "properties": {
                                        "status": {
                                            "type": "string",
                                            "example": "success"
                                        },
                                        "data": {
                                            "properties": {
                                                "state": {
                                                    "$ref": "#/components/schemas/StateListItem"
                                                },
                                                "lga": {
                                                    "$ref": "#/components/schemas/LgaListItem"
                                                },
                                                "ward": {
                                                    "$ref": "#/components/schemas/WardListItem"
                                                },
                                                "pollingUnits": {
                                                    "type": "array",
                                                    "items": {
                                                        "$ref": "#/components/schemas/PollingUnit"
                                                    }
                                                },
                                                "total": {
                                                    "type": "integer"
                                                },
                                                "page": {
                                                    "type": "integer"
                                                },
                                                "limit": {
                                                    "type": "integer"
                                                },
                                                "pages": {
                                                    "type": "integer"
                                                }
                                            },
                                            "type": "object"
                                        },
                                        "timestamp": {
                                            "type": "string",
                                            "format": "date-time"
                                        }
                                    },
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Resource not found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/ErrorResponse"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "StateListItem": {
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "code": {
                        "type": "string",
                        "example": "LA"
                    },
                    "name": {
                        "type": "string",
                        "example": "Lagos"
                    },
                    "active": {
                        "type": "boolean"
                    }
                },
                "type": "object"
            },
            "StateDetail": {
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "code": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "active": {
                        "type": "boolean"
                    },
                    "lgaCount": {
                        "type": "integer"
                    },
                    "wardCount": {
                        "type": "integer"
                    },
                    "pollingUnitCount": {
                        "type": "integer"
                    }
                },
                "type": "object"
            },
            "LgaListItem": {
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "code": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "active": {
                        "type": "boolean"
                    },
                    "stateId": {
                        "type": "string",
                        "format": "uuid"
                    }
                },
                "type": "object"
            },
            "LgaDetail": {
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "code": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "active": {
                        "type": "boolean"
                    },
                    "state": {
                        "$ref": "#/components/schemas/StateListItem"
                    },
                    "wardCount": {
                        "type": "integer"
                    },
                    "pollingUnitCount": {
                        "type": "integer"
                    }
                },
                "type": "object"
            },
            "WardListItem": {
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "code": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "active": {
                        "type": "boolean"
                    }
                },
                "type": "object"
            },
            "WardDetail": {
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "code": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "active": {
                        "type": "boolean"
                    },
                    "state": {
                        "$ref": "#/components/schemas/StateListItem"
                    },
                    "lga": {
                        "$ref": "#/components/schemas/LgaListItem"
                    },
                    "pollingUnitCount": {
                        "type": "integer"
                    },
                    "pollingUnits": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/PollingUnit"
                        }
                    }
                },
                "type": "object"
            },
            "PollingUnit": {
                "properties": {
                    "id": {
                        "type": "string",
                        "format": "uuid"
                    },
                    "name": {
                        "type": "string"
                    },
                    "code": {
                        "type": "string"
                    },
                    "puCode": {
                        "type": "string"
                    },
                    "active": {
                        "type": "boolean"
                    },
                    "accredited": {
                        "type": "boolean"
                    }
                },
                "type": "object"
            },
            "ErrorResponse": {
                "properties": {
                    "status": {
                        "type": "string",
                        "example": "error"
                    },
                    "message": {
                        "type": "string"
                    },
                    "timestamp": {
                        "type": "string",
                        "format": "date-time"
                    }
                },
                "type": "object"
            }
        }
    },
    "tags": [
        {
            "name": "Summary"
        },
        {
            "name": "States"
        },
        {
            "name": "LGAs"
        },
        {
            "name": "Wards"
        },
        {
            "name": "Polling Units"
        }
    ]
}