{
  "openapi": "3.0.3",
  "info": {
    "title": "Data Anonymizer",
    "description": "Mask, hash, and pseudonymize (HMAC) sensitive values, plus k-anonymity checks for datasets — stateless, pure compute.",
    "version": "1.0.0"
  },
  "components": {
    "schemas": {}
  },
  "paths": {
    "/mask": {
      "post": {
        "summary": "Mask a string",
        "tags": [
          "Anonymizer"
        ],
        "description": "Mask a string according to strategy, with special handling for emails.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "value"
                ],
                "properties": {
                  "value": {
                    "type": "string"
                  },
                  "strategy": {
                    "type": "string",
                    "enum": [
                      "partial",
                      "full"
                    ],
                    "default": "partial"
                  },
                  "keepStart": {
                    "type": "integer",
                    "default": 1
                  },
                  "keepEnd": {
                    "type": "integer",
                    "default": 1
                  },
                  "maskChar": {
                    "type": "string",
                    "default": "*"
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "value": "john.doe@example.com",
                "strategy": "partial"
              }
            }
          }
        },
        "responses": {
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Bad request",
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/hash": {
      "post": {
        "summary": "Hash a string",
        "tags": [
          "Anonymizer"
        ],
        "description": "Compute a SHA-256 or SHA-512 hash, optionally salted.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "value"
                ],
                "properties": {
                  "value": {
                    "type": "string"
                  },
                  "algorithm": {
                    "type": "string",
                    "enum": [
                      "sha256",
                      "sha512"
                    ],
                    "default": "sha256"
                  },
                  "salt": {
                    "type": "string"
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "value": "secret",
                "algorithm": "sha256"
              }
            }
          }
        },
        "responses": {
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Bad request",
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/pseudonymize": {
      "post": {
        "summary": "Pseudonymize values",
        "tags": [
          "Anonymizer"
        ],
        "description": "Generate deterministic tokens via HMAC‑SHA256.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "values",
                  "secret"
                ],
                "properties": {
                  "values": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "secret": {
                    "type": "string"
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "values": [
                  "alice",
                  "bob"
                ],
                "secret": "mysecret"
              }
            }
          }
        },
        "responses": {
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Bad request",
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/k-anonymity": {
      "post": {
        "summary": "Check k‑anonymity",
        "tags": [
          "Anonymizer"
        ],
        "description": "Assess whether a dataset satisfies k‑anonymity.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "records",
                  "quasiIdentifiers"
                ],
                "properties": {
                  "records": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "quasiIdentifiers": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "k": {
                    "type": "integer",
                    "default": 2
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "records": [
                  {
                    "age": 30,
                    "zip": "12345"
                  },
                  {
                    "age": 30,
                    "zip": "12345"
                  }
                ],
                "quasiIdentifiers": [
                  "age",
                  "zip"
                ],
                "k": 2
              }
            }
          }
        },
        "responses": {
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "description": "Bad request",
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "servers": [
    {
      "url": "https://web-toolbox-api-production.up.railway.app/anonymize",
      "description": "Production"
    }
  ]
}