{
  "openapi": "3.1.0",
  "info": {
    "title": "Men’s API",
    "version": "1.0.0",
    "summary": "Questions and search over the texts of the portal.",
    "description": "Interfejsi portala Men’s za programe i AI agente. Odgovori se sastavljaju samo iz objavljenih tekstova, sa brojevima izvora. Interfejsi ne postavljaju dijagnoze i ne određuju doze. Preporučuje se razuman broj zahteva; preterano korišćenje se ograničava.",
    "license": {
      "name": "Sadržaj portala je zaštićen autorskim pravima izdavača",
      "url": "https://mens.rs/o-nama/"
    }
  },
  "servers": [
    {
      "url": "https://mens.rs"
    }
  ],
  "paths": {
    "/api/pitaj": {
      "post": {
        "operationId": "ask",
        "summary": "Ask Men’s AI a question",
        "description": "Postavlja pitanje na srpskom (do 300 znakova). Sa zaglavljem Accept: text/event-stream odgovor stiže kao tok događaja (meta, delta, no-answer, emergency, done, error), a inače kao JSON.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AskRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Odgovor sa brojevima izvora.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AskResult"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "Događaji meta, delta, no-answer, emergency, done i error."
                }
              }
            }
          },
          "400": {
            "description": "Pitanje nije ispravno.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Zahtev dolazi sa tuđeg sajta.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Previše zahteva.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "Odgovor trenutno nije moguće sastaviti.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/ask": {
      "get": {
        "operationId": "nlwebAsk",
        "summary": "NLWeb search over the texts",
        "description": "NLWeb kompatibilna pretraga. Režim list vraća tekstove, a summarize i generate dodaju odgovor sa izvorima.",
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 300
            }
          },
          {
            "name": "mode",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "list",
                "summarize",
                "generate"
              ],
              "default": "list"
            }
          },
          {
            "name": "prev",
            "in": "query",
            "description": "Prethodna pitanja, razdvojena zarezom.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Rezultati.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Pitanje nije ispravno.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "nlwebAskPost",
        "summary": "NLWeb search (v0.55 request body)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Rezultati.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Pitanje nije ispravno.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "mcp",
        "summary": "Model Context Protocol server (Streamable HTTP, JSON-RPC 2.0)",
        "description": "Alati: trazi_tekstove, procitaj_stranicu, pitaj_mens_ai. Server ne čuva stanje između zahteva.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC odgovor.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "202": {
            "description": "Obaveštenje je primljeno."
          }
        }
      }
    },
    "/ai/index.json": {
      "get": {
        "operationId": "passages",
        "summary": "All passages of the portal",
        "description": "Odlomci tekstova, pojmova i stranica poverenja, za pretragu i ugradnju.",
        "responses": {
          "200": {
            "description": "Indeks.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AskRequest": {
        "type": "object",
        "required": [
          "question"
        ],
        "properties": {
          "question": {
            "type": "string",
            "minLength": 2,
            "maxLength": 300
          },
          "t": {
            "type": "string",
            "description": "Slug teksta o kome je pitanje."
          },
          "p": {
            "type": "string",
            "description": "Slug pojma iz Wiki rečnika o kome je pitanje."
          },
          "previous": {
            "type": "string",
            "description": "Prethodno pitanje u razgovoru, samo radi razumevanja upućivanja."
          }
        }
      },
      "AskSource": {
        "type": "object",
        "required": [
          "n",
          "title",
          "path"
        ],
        "properties": {
          "n": {
            "type": "integer",
            "description": "Broj koji odgovor navodi u uglastim zagradama."
          },
          "title": {
            "type": "string"
          },
          "path": {
            "type": "string",
            "description": "Adresa teksta na portalu."
          },
          "section": {
            "type": "string"
          },
          "category": {
            "type": "string"
          }
        }
      },
      "AskResult": {
        "type": "object",
        "required": [
          "state",
          "answer",
          "sources"
        ],
        "properties": {
          "state": {
            "type": "string",
            "enum": [
              "answer",
              "no-answer",
              "emergency"
            ]
          },
          "answer": {
            "type": "string",
            "description": "Tekst sa oznakama izvora [n]. Prazan kada nema odgovora."
          },
          "sources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AskSource"
            }
          },
          "scope": {
            "type": "object",
            "properties": {
              "kind": {
                "type": "string"
              },
              "title": {
                "type": "string"
              },
              "path": {
                "type": "string"
              }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string",
            "enum": [
              "invalid-question",
              "forbidden-origin",
              "rate-limited",
              "unavailable"
            ]
          },
          "message": {
            "type": "string"
          }
        }
      }
    }
  }
}