{
  "openapi": "3.1.0",
  "info": {
    "title": "Eczane Adresi API",
    "version": "1.0.0",
    "description": "Türkiye'deki nöbetçi (on-duty) eczanelere erişim için açık veri API'si. Veri günde iki kez TEB ve T.C. Sağlık Bakanlığı kaynaklarından senkronize edilir.",
    "contact": { "email": "iletisim@eczaneadresi.com", "url": "https://eczaneadresi.com" },
    "license": { "name": "CC-BY-4.0", "url": "https://creativecommons.org/licenses/by/4.0/" }
  },
  "servers": [{ "url": "https://eczaneadresi.com" }],
  "paths": {
    "/api/public/v1/nearest-pharmacies": {
      "get": {
        "operationId": "get_nearest_pharmacies",
        "summary": "Verilen koordinata en yakın nöbetçi eczaneleri döner.",
        "parameters": [
          { "name": "lat", "in": "query", "required": true, "schema": { "type": "number" }, "description": "WGS84 enlem" },
          { "name": "lng", "in": "query", "required": true, "schema": { "type": "number" }, "description": "WGS84 boylam" },
          { "name": "radius", "in": "query", "required": false, "schema": { "type": "integer", "minimum": 500, "maximum": 25000, "default": 5000 }, "description": "Arama yarıçapı (metre)" },
          { "name": "limit", "in": "query", "required": false, "schema": { "type": "integer", "minimum": 1, "maximum": 25, "default": 10 } }
        ],
        "responses": {
          "200": {
            "description": "Başarılı",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PharmacyList" } } }
          },
          "400": { "description": "Geçersiz koordinat" }
        }
      }
    },
    "/api/public/v1/duty-pharmacies": {
      "get": {
        "operationId": "list_duty_pharmacies",
        "summary": "Belirli bir il (ve isteğe bağlı ilçe) için bugünün nöbetçi eczanelerini döner.",
        "parameters": [
          { "name": "city", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Türkçe il slug (örn. 'istanbul')." },
          { "name": "district", "in": "query", "required": false, "schema": { "type": "string" }, "description": "İlçe slug (örn. 'kadikoy')." },
          { "name": "limit", "in": "query", "required": false, "schema": { "type": "integer", "minimum": 1, "maximum": 200, "default": 50 } }
        ],
        "responses": {
          "200": { "description": "Başarılı", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/PharmacyList" } } } },
          "404": { "description": "İl bulunamadı" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Pharmacy": {
        "type": "object",
        "properties": {
          "id": { "type": "integer" },
          "name": { "type": "string" },
          "slug": { "type": "string" },
          "url": { "type": "string", "format": "uri" },
          "phone": { "type": "string", "nullable": true },
          "address": { "type": "string", "nullable": true },
          "city": { "type": "string", "nullable": true },
          "district": { "type": "string", "nullable": true },
          "lat": { "type": "number", "nullable": true },
          "lng": { "type": "number", "nullable": true },
          "distance_m": { "type": "number", "nullable": true, "description": "Sorgu noktasına metre cinsinden uzaklık (yalnızca koordinat sorgularında)" },
          "mapsUrl": { "type": "string", "format": "uri" }
        },
        "required": ["id", "name", "slug", "url"]
      },
      "PharmacyList": {
        "type": "object",
        "properties": {
          "date": { "type": "string", "format": "date" },
          "count": { "type": "integer" },
          "attribution": { "type": "string" },
          "source": { "type": "string", "format": "uri" },
          "pharmacies": { "type": "array", "items": { "$ref": "#/components/schemas/Pharmacy" } }
        },
        "required": ["date", "count", "pharmacies"]
      }
    }
  }
}
