{
  "openapi": "3.1.0",
  "info": {
    "title": "Doğum Haritası API",
    "version": "1.0.0",
    "description": "Türkçe doğum haritası (natal chart) hesaplama servisi. Gezegen konumları, ev başlangıçları ve açılar.",
    "contact": { "email": "info@dogumharitasi.pro", "url": "https://dogumharitasi.pro/" }
  },
  "servers": [{ "url": "https://dogumharitasi.pro" }],
  "paths": {
    "/haritam": {
      "post": {
        "operationId": "createNatalChart",
        "summary": "Doğum haritası hesaplar",
        "description": "Form verisiyle doğum haritası üretir. Accept: text/markdown gönderilirse markdown tablo, aksi halde HTML döner.",
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": ["name", "birthdate", "birthtime", "birthplace", "country", "_csrf"],
                "properties": {
                  "name": { "type": "string" },
                  "birthdate": { "type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$" },
                  "birthtime": { "type": "string", "pattern": "^\\d{2}:\\d{2}$" },
                  "birthplace": { "type": "string" },
                  "country": { "type": "string", "pattern": "^[A-Z]{2}$" },
                  "_csrf": { "type": "string", "description": "Ana sayfadaki formdan alınan CSRF token'ı" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Harita",
            "content": {
              "text/html": { "schema": { "type": "string" } },
              "text/markdown": { "schema": { "type": "string" } }
            }
          },
          "302": { "description": "Doğrulama hatası — ana sayfaya yönlendirir" },
          "503": { "description": "Harita üretilemedi" }
        }
      }
    },
    "/mcp": {
      "get": {
        "operationId": "getMcpServerCard",
        "summary": "MCP sunucu kartı",
        "responses": { "200": { "description": "Sunucu kartı", "content": { "application/json": { "schema": { "type": "object" } } } } }
      },
      "post": {
        "operationId": "callMcp",
        "summary": "MCP JSON-RPC 2.0 uç noktası (Streamable HTTP)",
        "security": [{}, { "bearerAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["jsonrpc", "method"],
                "properties": {
                  "jsonrpc": { "type": "string", "const": "2.0" },
                  "id": { "type": ["string", "number", "null"] },
                  "method": { "type": "string", "examples": ["initialize", "tools/list", "tools/call"] },
                  "params": { "type": "object" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "JSON-RPC yanıtı", "content": { "application/json": { "schema": { "type": "object" } } } },
          "401": { "description": "Geçersiz bearer token" },
          "429": { "description": "Anonim çağrı limiti aşıldı" }
        }
      }
    },
    "/oauth/token": {
      "post": {
        "operationId": "issueToken",
        "summary": "client_credentials ile erişim anahtarı",
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": ["grant_type", "client_id", "client_secret"],
                "properties": {
                  "grant_type": { "type": "string", "const": "client_credentials" },
                  "client_id": { "type": "string" },
                  "client_secret": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Erişim anahtarı",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "access_token": { "type": "string" },
                    "token_type": { "type": "string" },
                    "expires_in": { "type": "integer" },
                    "scope": { "type": "string" }
                  }
                }
              }
            }
          },
          "401": { "description": "İstemci kimliği hatalı" }
        }
      }
    },
    "/agent/register": {
      "post": {
        "operationId": "registerAgent",
        "summary": "Anonim agent istemcisi oluşturur",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": { "type": "object", "properties": { "name": { "type": "string" } } }
            }
          }
        },
        "responses": {
          "200": { "description": "İstemci kimliği ve gizli anahtarı", "content": { "application/json": { "schema": { "type": "object" } } } },
          "429": { "description": "Kayıt limiti aşıldı" }
        }
      }
    },
    "/health": {
      "get": {
        "operationId": "health",
        "summary": "Servis durumu",
        "responses": { "200": { "description": "ok", "content": { "application/json": { "schema": { "type": "object" } } } } }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": { "type": "http", "scheme": "bearer" }
    }
  }
}
