{
  "openapi": "3.0.3",
  "info": {
    "title": "APIShed",
    "description": "A modular HTTP API server. Each module owns its own versioned route prefix.",
    "version": "1.0.0"
  },
  "servers": [
    { "url": "https://apished.com" }
  ],
  "paths": {
    "/v1/rpncalc/rpn": {
      "post": {
        "summary": "Evaluate an RPN expression",
        "description": "Evaluates a Reverse Polish Notation expression. Full operator/function reference and number-literal syntax: GET /v1/rpncalc/readme.\n\nSupported tokens:\n- Basic arithmetic: + - * /\n- Exponentiation & modulo: ^ pow, % mod\n- Roots: sqrt, cbrt, nroot (x n nroot -> x^(1/n))\n- Trigonometry (radians): sin cos tan asin acos atan atan2\n- Hyperbolic: sinh cosh tanh\n- Logarithms & exponentials: ln log2 log10 logn (x base logn) exp exp2\n- Angle conversion: todeg torad\n- Rounding: ceil floor round trunc\n- Misc math: abs neg sign hypot fact\n- Bitwise (operands truncated to int64): & and, | or, xor, ~ not, << shl, >> shr, popcount\n- Constants: pi e phi inf\n\nNumber literals: decimal (3, 1.5, -7), hex (0xFF), binary (0b1010), octal (0o17).",
        "tags": ["rpncalc"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/RPNRequest" },
              "examples": {
                "basic": { "value": { "expr": "3 4 + 2 *" } },
                "scientific": { "value": { "expr": "2 10 pow 1 -" } },
                "hexOutput": { "value": { "expr": "3 4 + 2 *", "format": "hex" } }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Evaluation result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/RPNResult" },
                "example": { "result": 14 }
              }
            }
          },
          "400": {
            "description": "Invalid expression, malformed request body, or unsupported format",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "division by zero" }
              }
            }
          }
        }
      }
    },
    "/v1/rpncalc/readme": {
      "get": {
        "summary": "Full rpncalc module reference",
        "description": "Returns the rpncalc module's README as raw Markdown: complete list of operators/functions, number-literal syntax, error cases, and examples.",
        "tags": ["rpncalc"],
        "responses": {
          "200": {
            "description": "README.md contents",
            "content": {
              "text/markdown": {
                "schema": { "type": "string" }
              }
            }
          }
        }
      }
    },
    "/v1/idvalidate/pesel": {
      "post": {
        "summary": "Validate a Polish PESEL number",
        "description": "Checks the checksum of an 11-digit Polish national identification number (PESEL). On success, also decodes the embedded date of birth and sex. Full reference: GET /v1/idvalidate/readme.",
        "tags": ["idvalidate"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/IDValidateRequest" },
              "examples": {
                "valid": { "value": { "value": "44051401359" } }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validation result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/PESELResult" },
                "example": { "valid": true, "birthDate": "1944-05-14", "sex": "male" }
              }
            }
          },
          "400": {
            "description": "Malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid request body" }
              }
            }
          }
        }
      }
    },
    "/v1/idvalidate/nip": {
      "post": {
        "summary": "Validate a Polish NIP number",
        "description": "Checks the checksum of a 10-digit Polish tax identification number (NIP). Full reference: GET /v1/idvalidate/readme.",
        "tags": ["idvalidate"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/IDValidateRequest" },
              "examples": {
                "valid": { "value": { "value": "5260001246" } }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validation result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/IDValidateResult" },
                "example": { "valid": true }
              }
            }
          },
          "400": {
            "description": "Malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid request body" }
              }
            }
          }
        }
      }
    },
    "/v1/idvalidate/regon": {
      "post": {
        "summary": "Validate a Polish REGON number",
        "description": "Checks the checksum of a 9- or 14-digit Polish business registry number (REGON). Full reference: GET /v1/idvalidate/readme.",
        "tags": ["idvalidate"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/IDValidateRequest" },
              "examples": {
                "valid9": { "value": { "value": "123456785" } },
                "valid14": { "value": { "value": "12345678500120" } }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validation result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/IDValidateResult" },
                "example": { "valid": true }
              }
            }
          },
          "400": {
            "description": "Malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid request body" }
              }
            }
          }
        }
      }
    },
    "/v1/idvalidate/readme": {
      "get": {
        "summary": "Full idvalidate module reference",
        "description": "Returns the idvalidate module's README as raw Markdown: checksum algorithms, request/response shapes, and examples for PESEL, NIP, and REGON.",
        "tags": ["idvalidate"],
        "responses": {
          "200": {
            "description": "README.md contents",
            "content": {
              "text/markdown": {
                "schema": { "type": "string" }
              }
            }
          }
        }
      }
    },
    "/v1/checksum/luhn": {
      "post": {
        "summary": "Validate a Luhn (mod-10) checksum",
        "description": "Generic Luhn checksum used by payment card numbers, IMEI numbers, and similar identifiers. Full reference: GET /v1/checksum/readme.",
        "tags": ["checksum"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ChecksumRequest" },
              "examples": { "valid": { "value": { "value": "4532015112830366" } } }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validation result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ChecksumResult" },
                "example": { "valid": true }
              }
            }
          },
          "400": {
            "description": "Malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid request body" }
              }
            }
          }
        }
      }
    },
    "/v1/checksum/isbn": {
      "post": {
        "summary": "Validate an ISBN-10 or ISBN-13",
        "description": "Checks a 10- or 13-character ISBN checksum. Full reference: GET /v1/checksum/readme.",
        "tags": ["checksum"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ChecksumRequest" },
              "examples": {
                "isbn10": { "value": { "value": "0306406152" } },
                "isbn13": { "value": { "value": "9780306406157" } }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validation result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ChecksumResult" },
                "example": { "valid": true }
              }
            }
          },
          "400": {
            "description": "Malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid request body" }
              }
            }
          }
        }
      }
    },
    "/v1/checksum/ean": {
      "post": {
        "summary": "Validate an EAN/UPC/GTIN barcode",
        "description": "Checks an 8, 12 (UPC-A), 13, or 14 digit GTIN barcode checksum. Full reference: GET /v1/checksum/readme.",
        "tags": ["checksum"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ChecksumRequest" },
              "examples": { "valid": { "value": { "value": "4006381333931" } } }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validation result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ChecksumResult" },
                "example": { "valid": true }
              }
            }
          },
          "400": {
            "description": "Malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid request body" }
              }
            }
          }
        }
      }
    },
    "/v1/checksum/iban": {
      "post": {
        "summary": "Validate an IBAN",
        "description": "Checks an IBAN's length for its issuing country and its mod-97 checksum. Does not decompose the BBAN or resolve a BIC. Full reference: GET /v1/checksum/readme.",
        "tags": ["checksum"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ChecksumRequest" },
              "examples": { "valid": { "value": { "value": "DE89370400440532013000" } } }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validation result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ChecksumResult" },
                "example": { "valid": true }
              }
            }
          },
          "400": {
            "description": "Malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid request body" }
              }
            }
          }
        }
      }
    },
    "/v1/checksum/vateu": {
      "post": {
        "summary": "Validate an EU VAT number's format",
        "description": "Format validation only (no VIES lookup) for all 27 EU member states plus Northern Ireland (XI). Full reference: GET /v1/checksum/readme.",
        "tags": ["checksum"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ChecksumRequest" },
              "examples": { "valid": { "value": { "value": "DE123456789" } } }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validation result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ChecksumResult" },
                "example": { "valid": true }
              }
            }
          },
          "400": {
            "description": "Malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid request body" }
              }
            }
          }
        }
      }
    },
    "/v1/checksum/swiftbic": {
      "post": {
        "summary": "Validate a SWIFT/BIC code's format",
        "description": "Structural format validation only (8 or 11 characters; country code not cross-checked against ISO 3166-1). Full reference: GET /v1/checksum/readme.",
        "tags": ["checksum"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ChecksumRequest" },
              "examples": { "valid": { "value": { "value": "DEUTDEFF" } } }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validation result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ChecksumResult" },
                "example": { "valid": true }
              }
            }
          },
          "400": {
            "description": "Malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid request body" }
              }
            }
          }
        }
      }
    },
    "/v1/checksum/readme": {
      "get": {
        "summary": "Full checksum module reference",
        "description": "Returns the checksum module's README as raw Markdown: algorithms and examples for Luhn, ISBN, EAN/UPC, IBAN, VAT-EU, and SWIFT/BIC.",
        "tags": ["checksum"],
        "responses": {
          "200": {
            "description": "README.md contents",
            "content": {
              "text/markdown": {
                "schema": { "type": "string" }
              }
            }
          }
        }
      }
    },
    "/v1/hash/digest": {
      "post": {
        "summary": "Compute a hash digest",
        "description": "Hashes input (decoded per encoding) with the given algorithm and returns the digest as lowercase hex. Full reference and known test vectors: GET /v1/hash/readme.",
        "tags": ["hash"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/DigestRequest" },
              "examples": {
                "text": { "value": { "algo": "sha256", "input": "hello" } },
                "hex": { "value": { "algo": "sha256", "input": "68656c6c6f", "encoding": "hex" } }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Digest result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/DigestResult" },
                "example": { "algo": "sha256", "digest": "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" }
              }
            }
          },
          "400": {
            "description": "Unsupported algorithm/encoding, invalid input, or malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "unsupported algorithm \"foo\": expected one of md5, sha1, sha256, sha512, crc32" }
              }
            }
          }
        }
      }
    },
    "/v1/hash/readme": {
      "get": {
        "summary": "Full hash module reference",
        "description": "Returns the hash module's README as raw Markdown: algorithm/encoding options and known test vectors.",
        "tags": ["hash"],
        "responses": {
          "200": {
            "description": "README.md contents",
            "content": {
              "text/markdown": {
                "schema": { "type": "string" }
              }
            }
          }
        }
      }
    },
    "/v1/text/count": {
      "post": {
        "summary": "Count occurrences of a substring",
        "description": "Counts non-overlapping occurrences of substring in text. Full reference: GET /v1/text/readme.",
        "tags": ["text"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/TextCountRequest" },
              "examples": { "strawberry": { "value": { "text": "strawberry", "substring": "r" } } }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Count result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TextCountResult" },
                "example": { "count": 3 }
              }
            }
          },
          "400": {
            "description": "Empty substring or malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "substring must not be empty" }
              }
            }
          }
        }
      }
    },
    "/v1/text/wordcount": {
      "post": {
        "summary": "Count whitespace-delimited words",
        "description": "Full reference: GET /v1/text/readme.",
        "tags": ["text"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/TextRequest" },
              "examples": { "valid": { "value": { "text": "the quick brown fox" } } }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Word count result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TextWordCountResult" },
                "example": { "words": 4 }
              }
            }
          },
          "400": {
            "description": "Malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid request body" }
              }
            }
          }
        }
      }
    },
    "/v1/text/reverse": {
      "post": {
        "summary": "Reverse text by Unicode code point",
        "description": "Full reference: GET /v1/text/readme.",
        "tags": ["text"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/TextRequest" },
              "examples": { "valid": { "value": { "text": "café" } } }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Reverse result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TextReverseResult" },
                "example": { "reversed": "éfac" }
              }
            }
          },
          "400": {
            "description": "Malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid request body" }
              }
            }
          }
        }
      }
    },
    "/v1/text/palindrome": {
      "post": {
        "summary": "Check whether text is a palindrome",
        "description": "Full reference: GET /v1/text/readme.",
        "tags": ["text"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/TextPalindromeRequest" },
              "examples": {
                "phrase": { "value": { "text": "A man, a plan, a canal: Panama", "ignoreCase": true, "ignoreNonAlnum": true } }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Palindrome result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TextPalindromeResult" },
                "example": { "palindrome": true }
              }
            }
          },
          "400": {
            "description": "Malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid request body" }
              }
            }
          }
        }
      }
    },
    "/v1/text/charat": {
      "post": {
        "summary": "Get the 0-indexed character at a position",
        "description": "Full reference: GET /v1/text/readme.",
        "tags": ["text"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/TextCharAtRequest" },
              "examples": { "valid": { "value": { "text": "strawberry", "index": 0 } } }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Character result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TextCharAtResult" },
                "example": { "char": "s" }
              }
            }
          },
          "400": {
            "description": "Out-of-range index or malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "index 10 out of range: text has 10 characters (valid range 0..9)" }
              }
            }
          }
        }
      }
    },
    "/v1/text/sort": {
      "post": {
        "summary": "Sort text's characters or words alphabetically",
        "description": "Full reference: GET /v1/text/readme.",
        "tags": ["text"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/TextSortRequest" },
              "examples": { "chars": { "value": { "text": "banana", "by": "chars" } } }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sort result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TextSortResult" },
                "example": { "sorted": "aaabnn" }
              }
            }
          },
          "400": {
            "description": "Unsupported 'by' value or malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "unsupported by \"letters\": expected \"chars\" or \"words\"" }
              }
            }
          }
        }
      }
    },
    "/v1/text/stats": {
      "post": {
        "summary": "Compute descriptive statistics for text",
        "description": "Counts, character-type breakdown, per-character frequency, and word-length stats. Full reference: GET /v1/text/readme.",
        "tags": ["text"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/TextRequest" },
              "examples": { "valid": { "value": { "text": "Hello, World! 123" } } }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Stats result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TextStatsResult" },
                "example": {
                  "runes": 17, "bytes": 17, "words": 3, "lines": 1, "uniqueRunes": 13,
                  "charTypes": { "letters": 10, "digits": 3, "spaces": 2, "punctuation": 2, "other": 0 },
                  "charFrequency": { "H": 1, "e": 1, "l": 3, "o": 2 },
                  "wordLengths": { "min": 3, "max": 6, "average": 5, "shortest": "123", "longest": "Hello," }
                }
              }
            }
          },
          "400": {
            "description": "Malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid request body" }
              }
            }
          }
        }
      }
    },
    "/v1/text/readme": {
      "get": {
        "summary": "Full text module reference",
        "description": "Returns the text module's README as raw Markdown: operations, request/response shapes, and Unicode handling notes.",
        "tags": ["text"],
        "responses": {
          "200": {
            "description": "README.md contents",
            "content": {
              "text/markdown": {
                "schema": { "type": "string" }
              }
            }
          }
        }
      }
    },
    "/v1/datemath/diff": {
      "post": {
        "summary": "Day difference between two dates",
        "description": "Returns to minus from in whole days (negative if to is before from). Full reference: GET /v1/datemath/readme.",
        "tags": ["datemath"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/DateDiffRequest" },
              "examples": { "valid": { "value": { "from": "2026-01-01", "to": "2026-03-01" } } }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Diff result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/DateDiffResult" },
                "example": { "days": 59 }
              }
            }
          },
          "400": {
            "description": "Invalid date or malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid date \"2026-02-30\": expected YYYY-MM-DD" }
              }
            }
          }
        }
      }
    },
    "/v1/datemath/businessdays": {
      "post": {
        "summary": "Business-day count between two dates",
        "description": "Counts days in [from, to] (inclusive on both ends) whose weekday is in weekdays (default Mon-Fri) and which aren't in holidays. Full reference: GET /v1/datemath/readme.",
        "tags": ["datemath"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/BusinessDaysRequest" },
              "examples": { "valid": { "value": { "from": "2026-08-17", "to": "2026-08-23" } } }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Business-day count result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/BusinessDaysResult" },
                "example": { "businessDays": 5 }
              }
            }
          },
          "400": {
            "description": "Invalid date, invalid weekday, or malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid weekday \"funday\": expected one of sun, mon, tue, wed, thu, fri, sat" }
              }
            }
          }
        }
      }
    },
    "/v1/datemath/leapyear": {
      "post": {
        "summary": "Check whether a year is a leap year",
        "description": "Full reference: GET /v1/datemath/readme.",
        "tags": ["datemath"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/LeapYearRequest" },
              "examples": { "valid": { "value": { "year": 2024 } } }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Leap-year result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/LeapYearResult" },
                "example": { "leapYear": true }
              }
            }
          },
          "400": {
            "description": "Malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid request body" }
              }
            }
          }
        }
      }
    },
    "/v1/datemath/age": {
      "post": {
        "summary": "Age in whole years as of a date",
        "description": "asOf is optional, defaults to the current UTC date. A Feb-29 birthDate is treated as falling on March 1 in a non-leap asOf year. Full reference: GET /v1/datemath/readme.",
        "tags": ["datemath"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/AgeRequest" },
              "examples": { "valid": { "value": { "birthDate": "2000-02-29", "asOf": "2026-02-28" } } }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Age result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/AgeResult" },
                "example": { "age": 25 }
              }
            }
          },
          "400": {
            "description": "Invalid date or malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid date \"2026-02-30\": expected YYYY-MM-DD" }
              }
            }
          }
        }
      }
    },
    "/v1/datemath/dayofweek": {
      "post": {
        "summary": "Day of the week for a date",
        "description": "Full reference: GET /v1/datemath/readme.",
        "tags": ["datemath"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/DayOfWeekRequest" },
              "examples": { "valid": { "value": { "date": "2026-08-17" } } }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Day-of-week result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/DayOfWeekResult" },
                "example": { "dayOfWeek": "Monday", "isoWeekday": 1 }
              }
            }
          },
          "400": {
            "description": "Invalid date or malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid date \"2026-02-30\": expected YYYY-MM-DD" }
              }
            }
          }
        }
      }
    },
    "/v1/datemath/add": {
      "post": {
        "summary": "Add years/months/days to a date",
        "description": "years/months are applied together with end-of-month clamping (e.g. 2026-01-31 + 1 month = 2026-02-28, not an overflowed 2026-03-03); days is then applied as plain calendar-day arithmetic. Full reference: GET /v1/datemath/readme.",
        "tags": ["datemath"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/AddDateRequest" },
              "examples": { "clamping": { "value": { "date": "2026-01-31", "months": 1 } } }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Add result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/AddDateResult" },
                "example": { "result": "2026-02-28" }
              }
            }
          },
          "400": {
            "description": "Invalid date or malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid date \"2026-02-30\": expected YYYY-MM-DD" }
              }
            }
          }
        }
      }
    },
    "/v1/datemath/readme": {
      "get": {
        "summary": "Full datemath module reference",
        "description": "Returns the datemath module's README as raw Markdown: all operations, the end-of-month clamping behavior, and examples.",
        "tags": ["datemath"],
        "responses": {
          "200": {
            "description": "README.md contents",
            "content": {
              "text/markdown": {
                "schema": { "type": "string" }
              }
            }
          }
        }
      }
    },
    "/v1/validate/regex": {
      "post": {
        "summary": "Test a string against a regular expression",
        "description": "Go's regexp package: RE2 syntax, not PCRE (no backreferences or lookaround). Full reference: GET /v1/validate/readme.",
        "tags": ["validate"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/RegexRequest" },
              "examples": { "valid": { "value": { "pattern": "^(\\w+)@(\\w+)$", "input": "alice@wonderland" } } }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Match result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/RegexResult" },
                "example": { "matches": true, "match": "alice@wonderland", "groups": ["alice", "wonderland"] }
              }
            }
          },
          "400": {
            "description": "Invalid regex pattern or malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid regex pattern: error parsing regexp: missing closing ]: `[abc`" }
              }
            }
          }
        }
      }
    },
    "/v1/validate/email": {
      "post": {
        "summary": "Validate an email address's format",
        "description": "RFC 5322 syntax validation only (not deliverability). Full reference: GET /v1/validate/readme.",
        "tags": ["validate"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ValidateValueRequest" },
              "examples": { "valid": { "value": { "value": "user@example.com" } } }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validation result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ValidateResult" },
                "example": { "valid": true }
              }
            }
          },
          "400": {
            "description": "Malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid request body" }
              }
            }
          }
        }
      }
    },
    "/v1/validate/url": {
      "post": {
        "summary": "Validate a URL's format",
        "description": "Checks for a well-formed absolute URL (scheme + host) — syntax only, not reachability. Full reference: GET /v1/validate/readme.",
        "tags": ["validate"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ValidateValueRequest" },
              "examples": { "valid": { "value": { "value": "https://example.com/path?q=1" } } }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validation result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ValidateResult" },
                "example": { "valid": true }
              }
            }
          },
          "400": {
            "description": "Malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid request body" }
              }
            }
          }
        }
      }
    },
    "/v1/validate/jsonschema": {
      "post": {
        "summary": "Validate a JSON document against a JSON Schema",
        "description": "Draft-07 or 2020-12. Reports one specific violation per call, not an aggregated list. Full reference: GET /v1/validate/readme.",
        "tags": ["validate"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/JSONSchemaRequest" },
              "examples": {
                "invalid": {
                  "value": {
                    "schema": { "type": "object", "properties": { "name": { "type": "string" }, "age": { "type": "integer", "minimum": 0 } }, "required": ["name", "age"] },
                    "document": { "name": "Al" }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validation result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ValidateResult" },
                "example": { "valid": false, "reason": "validating root: required: missing properties: [\"age\"]" }
              }
            }
          },
          "400": {
            "description": "Malformed schema or document JSON, or malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "invalid schema: expected a JSON object, got string" }
              }
            }
          }
        }
      }
    },
    "/v1/validate/readme": {
      "get": {
        "summary": "Full validate module reference",
        "description": "Returns the validate module's README as raw Markdown: regex/email/URL/JSON Schema operations, limitations, and examples.",
        "tags": ["validate"],
        "responses": {
          "200": {
            "description": "README.md contents",
            "content": {
              "text/markdown": {
                "schema": { "type": "string" }
              }
            }
          }
        }
      }
    },
    "/v1/tokens/count": {
      "post": {
        "summary": "Count tokens under an OpenAI-compatible tokenizer",
        "description": "Provide exactly one of model or encoding. OpenAI-compatible (tiktoken) encodings only — no Claude/Anthropic tokenizer. Full reference: GET /v1/tokens/readme.",
        "tags": ["tokens"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/TokenCountRequest" },
              "examples": {
                "byModel": { "value": { "text": "Hello, world!", "model": "gpt-4o" } },
                "byEncoding": { "value": { "text": "Hello, world!", "encoding": "cl100k_base" } }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token count result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TokenCountResult" },
                "example": { "tokens": 4, "encoding": "o200k_base" }
              }
            }
          },
          "400": {
            "description": "Unknown model/encoding, both or neither of model/encoding provided, or malformed request body",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/Error" },
                "example": { "error": "provide exactly one of model or encoding" }
              }
            }
          }
        }
      }
    },
    "/v1/tokens/readme": {
      "get": {
        "summary": "Full tokens module reference",
        "description": "Returns the tokens module's README as raw Markdown: supported encodings, model resolution, and scope notes.",
        "tags": ["tokens"],
        "responses": {
          "200": {
            "description": "README.md contents",
            "content": {
              "text/markdown": {
                "schema": { "type": "string" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "RPNRequest": {
        "type": "object",
        "required": ["expr"],
        "properties": {
          "expr": {
            "type": "string",
            "description": "Space-separated RPN expression. See GET /v1/rpncalc/readme for the full token reference.",
            "example": "3 4 + 2 *"
          },
          "format": {
            "type": "string",
            "description": "Output number format. Non-'dec' formats require a whole-number result.",
            "enum": ["dec", "hex", "bin", "oct"],
            "default": "dec"
          }
        }
      },
      "RPNResult": {
        "type": "object",
        "properties": {
          "result": {
            "description": "Number when format is 'dec' (default), string (e.g. '0x1c') otherwise.",
            "oneOf": [
              { "type": "number" },
              { "type": "string" }
            ]
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": { "type": "string" }
        }
      },
      "IDValidateRequest": {
        "type": "object",
        "required": ["value"],
        "properties": {
          "value": {
            "type": "string",
            "description": "Digits-only identifier to validate.",
            "example": "44051401359"
          }
        }
      },
      "IDValidateResult": {
        "type": "object",
        "properties": {
          "valid": { "type": "boolean" },
          "reason": { "type": "string", "description": "Present when valid is false." }
        }
      },
      "PESELResult": {
        "type": "object",
        "properties": {
          "valid": { "type": "boolean" },
          "reason": { "type": "string", "description": "Present when valid is false." },
          "birthDate": { "type": "string", "description": "Present when valid is true.", "example": "1944-05-14" },
          "sex": { "type": "string", "description": "Present when valid is true.", "enum": ["male", "female"] }
        }
      },
      "ChecksumRequest": {
        "type": "object",
        "required": ["value"],
        "properties": {
          "value": {
            "type": "string",
            "description": "Identifier to validate.",
            "example": "4532015112830366"
          }
        }
      },
      "ChecksumResult": {
        "type": "object",
        "properties": {
          "valid": { "type": "boolean" },
          "reason": { "type": "string", "description": "Present when valid is false." }
        }
      },
      "DigestRequest": {
        "type": "object",
        "required": ["algo", "input"],
        "properties": {
          "algo": {
            "type": "string",
            "description": "Hash algorithm.",
            "enum": ["md5", "sha1", "sha256", "sha512", "crc32"],
            "example": "sha256"
          },
          "input": {
            "type": "string",
            "description": "Data to hash, encoded per 'encoding'.",
            "example": "hello"
          },
          "encoding": {
            "type": "string",
            "description": "How 'input' is encoded.",
            "enum": ["text", "base64", "hex"],
            "default": "text"
          }
        }
      },
      "DigestResult": {
        "type": "object",
        "properties": {
          "algo": { "type": "string" },
          "digest": { "type": "string", "description": "Lowercase hex digest." }
        }
      },
      "TextRequest": {
        "type": "object",
        "required": ["text"],
        "properties": {
          "text": { "type": "string", "example": "strawberry" }
        }
      },
      "TextCountRequest": {
        "type": "object",
        "required": ["text", "substring"],
        "properties": {
          "text": { "type": "string", "example": "strawberry" },
          "substring": { "type": "string", "description": "Must be non-empty.", "example": "r" }
        }
      },
      "TextCountResult": {
        "type": "object",
        "properties": { "count": { "type": "integer" } }
      },
      "TextWordCountResult": {
        "type": "object",
        "properties": { "words": { "type": "integer" } }
      },
      "TextReverseResult": {
        "type": "object",
        "properties": { "reversed": { "type": "string" } }
      },
      "TextPalindromeRequest": {
        "type": "object",
        "required": ["text"],
        "properties": {
          "text": { "type": "string", "example": "racecar" },
          "ignoreCase": { "type": "boolean", "default": false },
          "ignoreNonAlnum": { "type": "boolean", "default": false }
        }
      },
      "TextPalindromeResult": {
        "type": "object",
        "properties": { "palindrome": { "type": "boolean" } }
      },
      "TextCharAtRequest": {
        "type": "object",
        "required": ["text", "index"],
        "properties": {
          "text": { "type": "string", "example": "strawberry" },
          "index": { "type": "integer", "description": "0-indexed.", "example": 0 }
        }
      },
      "TextCharAtResult": {
        "type": "object",
        "properties": { "char": { "type": "string" } }
      },
      "TextSortRequest": {
        "type": "object",
        "required": ["text"],
        "properties": {
          "text": { "type": "string", "example": "banana" },
          "by": { "type": "string", "enum": ["chars", "words"], "default": "chars" }
        }
      },
      "TextSortResult": {
        "type": "object",
        "properties": { "sorted": { "type": "string" } }
      },
      "TextCharTypeCounts": {
        "type": "object",
        "properties": {
          "letters": { "type": "integer" },
          "digits": { "type": "integer" },
          "spaces": { "type": "integer" },
          "punctuation": { "type": "integer" },
          "other": { "type": "integer" }
        }
      },
      "TextWordLengthStats": {
        "type": "object",
        "properties": {
          "min": { "type": "integer" },
          "max": { "type": "integer" },
          "average": { "type": "number" },
          "shortest": { "type": "string" },
          "longest": { "type": "string" }
        }
      },
      "TextStatsResult": {
        "type": "object",
        "properties": {
          "runes": { "type": "integer" },
          "bytes": { "type": "integer" },
          "words": { "type": "integer" },
          "lines": { "type": "integer" },
          "uniqueRunes": { "type": "integer" },
          "charTypes": { "$ref": "#/components/schemas/TextCharTypeCounts" },
          "charFrequency": { "type": "object", "additionalProperties": { "type": "integer" }, "description": "Exact per-character count, case-sensitive." },
          "wordLengths": { "$ref": "#/components/schemas/TextWordLengthStats" }
        }
      },
      "DateDiffRequest": {
        "type": "object",
        "required": ["from", "to"],
        "properties": {
          "from": { "type": "string", "example": "2026-01-01" },
          "to": { "type": "string", "example": "2026-03-01" }
        }
      },
      "DateDiffResult": {
        "type": "object",
        "properties": { "days": { "type": "integer" } }
      },
      "BusinessDaysRequest": {
        "type": "object",
        "required": ["from", "to"],
        "properties": {
          "from": { "type": "string", "example": "2026-08-17" },
          "to": { "type": "string", "example": "2026-08-23" },
          "weekdays": {
            "type": "array",
            "items": { "type": "string", "enum": ["sun", "mon", "tue", "wed", "thu", "fri", "sat"] },
            "description": "Optional, default [mon, tue, wed, thu, fri]."
          },
          "holidays": {
            "type": "array",
            "items": { "type": "string" },
            "description": "Optional list of YYYY-MM-DD dates to exclude."
          }
        }
      },
      "BusinessDaysResult": {
        "type": "object",
        "properties": { "businessDays": { "type": "integer" } }
      },
      "LeapYearRequest": {
        "type": "object",
        "required": ["year"],
        "properties": { "year": { "type": "integer", "example": 2024 } }
      },
      "LeapYearResult": {
        "type": "object",
        "properties": { "leapYear": { "type": "boolean" } }
      },
      "AgeRequest": {
        "type": "object",
        "required": ["birthDate"],
        "properties": {
          "birthDate": { "type": "string", "example": "2000-02-29" },
          "asOf": { "type": "string", "description": "Optional, defaults to the current UTC date.", "example": "2026-02-28" }
        }
      },
      "AgeResult": {
        "type": "object",
        "properties": { "age": { "type": "integer" } }
      },
      "DayOfWeekRequest": {
        "type": "object",
        "required": ["date"],
        "properties": { "date": { "type": "string", "example": "2026-08-17" } }
      },
      "DayOfWeekResult": {
        "type": "object",
        "properties": {
          "dayOfWeek": { "type": "string", "example": "Monday" },
          "isoWeekday": { "type": "integer", "description": "1=Monday..7=Sunday.", "example": 1 }
        }
      },
      "AddDateRequest": {
        "type": "object",
        "required": ["date"],
        "properties": {
          "date": { "type": "string", "example": "2026-01-31" },
          "years": { "type": "integer", "default": 0 },
          "months": { "type": "integer", "default": 0 },
          "days": { "type": "integer", "default": 0 }
        }
      },
      "AddDateResult": {
        "type": "object",
        "properties": { "result": { "type": "string" } }
      },
      "RegexRequest": {
        "type": "object",
        "required": ["pattern", "input"],
        "properties": {
          "pattern": { "type": "string", "description": "RE2 syntax.", "example": "^(\\w+)@(\\w+)$" },
          "input": { "type": "string", "example": "alice@wonderland" }
        }
      },
      "RegexResult": {
        "type": "object",
        "properties": {
          "matches": { "type": "boolean" },
          "match": { "type": "string", "description": "Present when matches is true." },
          "groups": { "type": "array", "items": { "type": "string" }, "description": "Present when matches is true." }
        }
      },
      "ValidateValueRequest": {
        "type": "object",
        "required": ["value"],
        "properties": {
          "value": { "type": "string" }
        }
      },
      "ValidateResult": {
        "type": "object",
        "properties": {
          "valid": { "type": "boolean" },
          "reason": { "type": "string", "description": "Present when valid is false." }
        }
      },
      "JSONSchemaRequest": {
        "type": "object",
        "required": ["schema", "document"],
        "properties": {
          "schema": { "type": "object", "description": "A JSON Schema (draft-07 or 2020-12)." },
          "document": { "description": "The JSON value to validate against schema. May be any JSON type." }
        }
      },
      "TokenCountRequest": {
        "type": "object",
        "required": ["text"],
        "properties": {
          "text": { "type": "string", "example": "Hello, world!" },
          "model": { "type": "string", "description": "Provide exactly one of model or encoding.", "example": "gpt-4o" },
          "encoding": { "type": "string", "enum": ["o200k_base", "cl100k_base"], "description": "Only these two are vendored; the library also knows p50k_base/p50k_edit/r50k_base but this endpoint doesn't." }
        }
      },
      "TokenCountResult": {
        "type": "object",
        "properties": {
          "tokens": { "type": "integer" },
          "encoding": { "type": "string", "description": "The encoding actually used." }
        }
      }
    }
  }
}
