{
  "openapi": "3.0.1",
  "info": {
    "title": "Hash Validator HTTP Proxy API",
    "description": "API REST para Validación Distribuida de Hashes usando Redis con TTL de 72 horas",
    "contact": {
      "name": "Detecno ClientGate",
      "email": "support@detecno.mx"
    },
    "version": "v1.0.0"
  },
  "paths": {
    "/hash/api/v1/validate": {
      "post": {
        "tags": [
          "Validación de Hashes"
        ],
        "summary": "Valida y registra un hash",
        "description": "Valida si un hash es nuevo y lo registra automáticamente en Redis con TTL de 72 horas. Operación atómica sin race conditions.",
        "operationId": "ValidateHash",
        "parameters": [
          {
            "name": "X-API-Key",
            "in": "header",
            "description": "API Key para autenticación. Requerida para todos los endpoints excepto /health",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ValidationRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/ValidationRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/ValidationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Hash validado exitosamente",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Request inválido - Hash vacío o nulo",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "API Key faltante o inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Error interno del servidor",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/hash/api/v1/exists/{hash}": {
      "get": {
        "tags": [
          "Consultas"
        ],
        "summary": "Verifica si un hash existe",
        "description": "Consulta si un hash ya está registrado sin modificar su estado. Útil para verificaciones previas.",
        "operationId": "CheckHashExists",
        "parameters": [
          {
            "name": "hash",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "correlationId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-API-Key",
            "in": "header",
            "description": "API Key para autenticación. Requerida para todos los endpoints excepto /health",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Consulta exitosa",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExistsResponse"
                }
              }
            }
          },
          "400": {
            "description": "Hash inválido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "API Key faltante o inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/hash/api/v1/info/{hash}": {
      "get": {
        "tags": [
          "Consultas"
        ],
        "summary": "Obtiene información del hash",
        "description": "Devuelve información detallada del hash incluyendo fecha de expiración y TTL restante.",
        "operationId": "GetHashInfo",
        "parameters": [
          {
            "name": "hash",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "correlationId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-API-Key",
            "in": "header",
            "description": "API Key para autenticación. Requerida para todos los endpoints excepto /health",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Información obtenida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HashInfoResponse"
                }
              }
            }
          },
          "400": {
            "description": "Hash inválido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "API Key faltante o inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/hash/api/v1/delete/{hash}": {
      "delete": {
        "tags": [
          "Administración"
        ],
        "summary": "Elimina un hash",
        "description": "Elimina un hash del registro. Útil para rollback o testing.",
        "operationId": "DeleteHash",
        "parameters": [
          {
            "name": "hash",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "correlationId",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-API-Key",
            "in": "header",
            "description": "API Key para autenticación. Requerida para todos los endpoints excepto /health",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Hash eliminado o no encontrado",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeleteResponse"
                }
              }
            }
          },
          "400": {
            "description": "Hash inválido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "API Key faltante o inválida",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/hash/api/v1/health": {
      "get": {
        "tags": [
          "Monitoreo"
        ],
        "summary": "Health check",
        "description": "Verifica el estado del servicio. No requiere autenticación.",
        "operationId": "HealthCheck",
        "responses": {
          "200": {
            "description": "Servicio funcionando correctamente",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "DeleteResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "hash": {
            "type": "string",
            "nullable": true
          },
          "deleted": {
            "type": "boolean"
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "correlationId": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "errorMessage": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ExistsResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "hash": {
            "type": "string",
            "nullable": true
          },
          "exists": {
            "type": "boolean"
          },
          "id": {
            "type": "string",
            "nullable": true
          },
          "uuid": {
            "type": "string",
            "nullable": true
          },
          "correlationId": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "HashInfoResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "hash": {
            "type": "string",
            "nullable": true
          },
          "exists": {
            "type": "boolean"
          },
          "id": {
            "type": "string",
            "nullable": true
          },
          "uuid": {
            "type": "string",
            "nullable": true
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "timeToLiveSeconds": {
            "type": "number",
            "format": "double",
            "nullable": true
          },
          "correlationId": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "HealthResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "nullable": true
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "version": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ValidationRequest": {
        "type": "object",
        "properties": {
          "hash": {
            "type": "string",
            "nullable": true
          },
          "id": {
            "type": "string",
            "nullable": true
          },
          "uuid": {
            "type": "string",
            "nullable": true
          },
          "correlationId": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "ValidationResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "isNew": {
            "type": "boolean"
          },
          "hash": {
            "type": "string",
            "nullable": true
          },
          "id": {
            "type": "string",
            "nullable": true
          },
          "uuid": {
            "type": "string",
            "nullable": true
          },
          "message": {
            "type": "string",
            "nullable": true
          },
          "correlationId": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      }
    },
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "description": "API Key para autenticación. Agrega el header X-API-Key con tu clave válida.",
        "name": "X-API-Key",
        "in": "header"
      }
    }
  }
}