{
  "openapi": "3.1.0",
  "info": {
    "title": "Rybmap Public API",
    "version": "1.0.0",
    "description": "Read-only public data for Rybmap, a Czech and Slovak fishing-water map. Fishing rules may change; users should verify restrictions with the relevant water operator before fishing."
  },
  "servers": [{ "url": "https://rybmap.cz", "description": "Production" }],
  "paths": {
    "/api/stats": {
      "get": {
        "operationId": "getCatalogueStatistics",
        "summary": "Get current fishing-water catalogue statistics",
        "description": "Returns counts for the public Rybmap catalogue and its geographic coverage.",
        "responses": {
          "200": { "description": "Catalogue statistics", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Statistics" } } } },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },
    "/api/reviry": {
      "get": {
        "operationId": "listFishingWaters",
        "summary": "List fishing waters",
        "description": "Searches and filters publicly visible fishing waters. Results are paginated.",
        "parameters": [
          { "name": "q", "in": "query", "description": "Free-text search term", "schema": { "type": "string", "maxLength": 200 } },
          { "name": "limit", "in": "query", "description": "Maximum number of results", "schema": { "type": "integer", "minimum": 1, "maximum": 100, "default": 50 } },
          { "name": "offset", "in": "query", "description": "Number of results to skip", "schema": { "type": "integer", "minimum": 0, "default": 0 } }
        ],
        "responses": {
          "200": { "description": "Fishing-water list", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/FishingWaterList" } } } },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },
    "/api/reviry/{id}": {
      "get": {
        "operationId": "getFishingWater",
        "summary": "Get a fishing water by ID",
        "description": "Returns a public fishing-water record, including available rules and location data.",
        "parameters": [{ "name": "id", "in": "path", "required": true, "description": "Numeric Rybmap water ID", "schema": { "type": "integer", "minimum": 1 } }],
        "responses": {
          "200": { "description": "Fishing-water detail", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/FishingWater" } } } },
          "404": { "description": "Fishing water not found" },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },
    "/api/reviry/geo": {
      "get": {
        "operationId": "listFishingWaterMapFeatures",
        "summary": "List map features for fishing waters",
        "description": "Returns public geographic features for map rendering.",
        "responses": {
          "200": { "description": "GeoJSON feature collection", "content": { "application/geo+json": { "schema": { "$ref": "#/components/schemas/GeoFeatureCollection" } } } },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },
    "/api/ryby/species": {
      "get": {
        "operationId": "listFishSpecies",
        "summary": "List fish species in the catalogue",
        "description": "Returns fish species and the number of public waters where each occurs.",
        "parameters": [{ "name": "q", "in": "query", "description": "Optional species-name filter", "schema": { "type": "string", "maxLength": 100 } }],
        "responses": {
          "200": { "description": "Species counts", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/SpeciesList" } } } },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    }
  },
  "components": {
    "responses": { "ServerError": { "description": "The service could not complete the request" } },
    "schemas": {
      "Statistics": { "type": "object", "required": ["total", "withGps"], "properties": { "total": { "type": "integer", "minimum": 0 }, "withGps": { "type": "integer", "minimum": 0 }, "withoutGps": { "type": "integer", "minimum": 0 }, "lastScrape": { "type": ["string", "null"], "format": "date-time" } } },
      "FishingWater": { "type": "object", "properties": { "id": { "type": "integer" }, "nazev": { "type": "string" }, "cislo": { "type": "string" }, "gps": { "type": ["object", "null"], "properties": { "lat": { "type": "number" }, "lng": { "type": "number" } } } } },
      "FishingWaterList": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/components/schemas/FishingWater" } }, "total": { "type": "integer", "minimum": 0 } } },
      "GeoFeatureCollection": { "type": "object", "required": ["type", "features"], "properties": { "type": { "const": "FeatureCollection" }, "features": { "type": "array", "items": { "type": "object" } } } },
      "SpeciesList": { "type": "object", "required": ["data", "total"], "properties": { "data": { "type": "object", "additionalProperties": { "type": "integer", "minimum": 0 } }, "total": { "type": "integer", "minimum": 0 } } }
    }
  }
}
