{
  "openapi": "3.0.3",
  "info": {
    "title": "VeredAi Knowledge API",
    "version": "1.0.0",
    "description": "Doorzoek de juridische kennisbank van VeredAi: wetgeving op artikelniveau, rechtspraak en Europese wetgeving."
  },
  "servers": [
    {
      "url": "/"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "SearchResult": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "external_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "snippet": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "language": {
            "type": "string"
          },
          "jurisdiction": {
            "type": "string"
          },
          "document_type": {
            "type": "string"
          },
          "decision_date": {
            "type": "string"
          },
          "score": {
            "type": "integer"
          }
        }
      },
      "Document": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "external_id": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "summary": {
            "type": "string"
          },
          "body": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "language": {
            "type": "string"
          },
          "jurisdiction": {
            "type": "string"
          },
          "law_area": {
            "type": "string"
          },
          "document_type": {
            "type": "string"
          },
          "decision_date": {
            "type": "string"
          },
          "harvested_at": {
            "type": "string"
          }
        }
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/api/knowledge/search": {
      "get": {
        "summary": "Doorzoek de kennisbank",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 3
            }
          },
          {
            "name": "lang",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "nl",
                "en"
              ]
            }
          },
          {
            "name": "jurisdiction",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "NL",
                "BE",
                "DE",
                "EU"
              ]
            }
          },
          {
            "name": "type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "wetgeving",
                "rechtspraak",
                "eu",
                "decentraal"
              ]
            }
          },
          {
            "name": "area",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "law",
            "in": "query",
            "required": false,
            "description": "Filter op wet of afkorting (bijvoorbeeld bw, awb of Burgerlijk Wetboek); zoekt uitsluitend in de lokale kennisindex.",
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          },
          {
            "name": "date_from",
            "in": "query",
            "required": false,
            "description": "Alleen documenten met een beslis- of publicatiedatum op of na deze datum (JJJJ-MM-DD).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "date_to",
            "in": "query",
            "required": false,
            "description": "Alleen documenten met een beslis- of publicatiedatum op of voor deze datum (JJJJ-MM-DD).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 25,
              "default": 10
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Zoekresultaten",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SearchResult"
                      }
                    },
                    "meta": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Ongeldige of ontbrekende API-sleutel",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Onvoldoende credits",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Abonnement zonder API-toegang",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Ongeldige parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Snelheidslimiet bereikt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/knowledge/documents/{uuid}": {
      "get": {
        "summary": "Volledig document",
        "parameters": [
          {
            "name": "uuid",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Document",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Document"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Ongeldige of ontbrekende API-sleutel",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Niet gevonden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/knowledge/health": {
      "get": {
        "summary": "Bronhealth per kennisbron",
        "responses": {
          "200": {
            "description": "Healthstatus",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Ongeldige of ontbrekende API-sleutel",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  }
}
