{
  "openapi": "3.0.3",
  "info": {
    "title": "Elpatrons Datumsrechner API",
    "version": "1.0.0",
    "description": "REST-API für Datumsberechnungen."
  },
  "servers": [
    { "url": "/api" }
  ],
  "paths": {
    "/tage_werktage": {
      "post": {
        "summary": "Berechnet die Anzahl der Tage oder Werktage zwischen zwei Daten.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "start": { "type": "string", "format": "date" },
                  "end": { "type": "string", "format": "date" },
                  "werktage": { "type": "boolean", "default": false },
                  "bundesland": { 
                    "type": "string", 
                    "description": "Bundesland-Kürzel für Feiertagsberücksichtigung (nur bei werktage=true)",
                    "enum": ["BW", "BY", "BE", "BB", "HB", "HH", "HE", "MV", "NI", "NW", "RP", "SL", "SN", "ST", "SH", "TH"]
                  }
                },
                "required": ["start", "end"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ergebnis der Berechnung.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": { "type": "integer" }
                  }
                }
              }
            }
          },
          "400": { "description": "Ungültige Eingabe" }
        }
      }
    },
    "/wochentag": {
      "post": {
        "summary": "Gibt den Wochentag zu einem Datum zurück.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "datum": { "type": "string", "format": "date" }
                },
                "required": ["datum"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Wochentag als Text.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": { "type": "string" }
                  }
                }
              }
            }
          },
          "400": { "description": "Ungültige Eingabe" }
        }
      }
    },
    "/kw_berechnen": {
      "post": {
        "summary": "Berechnet die Kalenderwoche zu einem Datum.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "datum": { "type": "string", "format": "date" }
                },
                "required": ["datum"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Kalenderwoche und Jahr.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": { "type": "string" },
                    "kw": { "type": "integer" },
                    "jahr": { "type": "integer" }
                  }
                }
              }
            }
          },
          "400": { "description": "Ungültige Eingabe" }
        }
      }
    },
    "/kw_datum": {
      "post": {
        "summary": "Berechnet Start- und Enddatum einer Kalenderwoche.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "jahr": { "type": "integer" },
                  "kw": { "type": "integer" }
                },
                "required": ["jahr", "kw"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Start- und Enddatum der Kalenderwoche.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": { "type": "string" },
                    "start": { "type": "string", "format": "date" },
                    "end": { "type": "string", "format": "date" }
                  }
                }
              }
            }
          },
          "400": { "description": "Ungültige Eingabe" }
        }
      }
    },
    "/plusminus": {
      "post": {
        "summary": "Berechnet ein Datum plus/minus X Tage, Wochen oder Monate.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "datum": { "type": "string", "format": "date" },
                  "anzahl": { "type": "integer" },
                  "einheit": { "type": "string", "enum": ["tage", "wochen", "monate"] },
                  "richtung": { "type": "string", "enum": ["add", "sub"], "default": "add" },
                  "werktage": { "type": "boolean", "default": false }
                },
                "required": ["datum", "anzahl", "einheit"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Berechnetes Datum.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "result": { "type": "string", "format": "date" }
                  }
                }
              }
            }
          },
          "400": { "description": "Ungültige Eingabe" }
        }
      }
    },
    "/monitor": {
      "get": {
        "summary": "Status- und Monitoring-Informationen zur App.",
        "responses": {
          "200": {
            "description": "Status-Objekt mit Uptime und Pageviews.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string" },
                    "message": { "type": "string" },
                    "time": { "type": "string", "format": "date-time" },
                    "uptime_seconds": { "type": "integer" },
                    "pageviews_last_7_days": { "type": "integer" }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
} 