{
  "openapi": "3.1.0",
  "info": {
    "title": "AppInitDev Processing API",
    "version": "1.0.0",
    "description": "API pública limitada. El parámetro op determina el esquema de entrada. PHP 8.1+; GD opcional. No enviar datos sensibles."
  },
  "servers": [
    {
      "url": "https://appinitdev.com/embed/api/v1"
    }
  ],
  "paths": {
    "/process.php": {
      "post": {
        "operationId": "process",
        "parameters": [
          {
            "name": "op",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "colors/convert",
                "colors/contrast",
                "math/statistics",
                "math/matrix",
                "text/convert",
                "data/csv-to-json",
                "image/resize",
                "image/convert",
                "audio/normalize"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "anyOf": [
                  {
                    "type": "object",
                    "properties": {
                      "hex": {
                        "type": "string",
                        "pattern": "^#?[0-9a-fA-F]{6}$"
                      }
                    },
                    "required": [
                      "hex"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "foreground": {
                        "type": "string",
                        "pattern": "^#?[0-9a-fA-F]{6}$"
                      },
                      "background": {
                        "type": "string",
                        "pattern": "^#?[0-9a-fA-F]{6}$"
                      }
                    },
                    "required": [
                      "foreground",
                      "background"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "values": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 10000,
                        "items": {
                          "type": "number"
                        }
                      }
                    },
                    "required": [
                      "values"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "a": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 30,
                        "items": {
                          "type": "array",
                          "minItems": 1,
                          "maxItems": 30,
                          "items": {
                            "type": "number"
                          }
                        }
                      },
                      "b": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 30,
                        "items": {
                          "type": "array",
                          "minItems": 1,
                          "maxItems": 30,
                          "items": {
                            "type": "number"
                          }
                        }
                      }
                    },
                    "required": [
                      "a",
                      "b"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "text": {
                        "type": "string",
                        "maxLength": 100000
                      },
                      "mode": {
                        "type": "string",
                        "enum": [
                          "upper-ascii",
                          "lower-ascii",
                          "base64",
                          "sha256",
                          "hex"
                        ]
                      }
                    },
                    "required": [
                      "text",
                      "mode"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "csv": {
                        "type": "string",
                        "maxLength": 200000
                      },
                      "delimiter": {
                        "type": "string",
                        "enum": [
                          ",",
                          ";",
                          "\t"
                        ]
                      }
                    },
                    "required": [
                      "csv"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "base64": {
                        "type": "string",
                        "maxLength": 2000004
                      },
                      "width": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 2048
                      },
                      "height": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 2048
                      },
                      "format": {
                        "type": "string",
                        "enum": [
                          "png",
                          "jpeg",
                          "webp"
                        ]
                      }
                    },
                    "required": [
                      "base64",
                      "width",
                      "height"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "base64": {
                        "type": "string",
                        "maxLength": 2000004
                      },
                      "format": {
                        "type": "string",
                        "enum": [
                          "png",
                          "jpeg",
                          "webp"
                        ]
                      }
                    },
                    "required": [
                      "base64"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "base64": {
                        "type": "string",
                        "maxLength": 2000004
                      },
                      "peak": {
                        "type": "number",
                        "exclusiveMinimum": 0,
                        "maximum": 1
                      }
                    },
                    "required": [
                      "base64"
                    ]
                  }
                ]
              },
              "examples": {
                "colors_convert": {
                  "summary": "HEX a RGB y luminancia",
                  "value": {
                    "hex": "#01875f"
                  }
                },
                "colors_contrast": {
                  "summary": "Contraste WCAG",
                  "value": {
                    "foreground": "#000000",
                    "background": "#FFFFFF"
                  }
                },
                "math_statistics": {
                  "summary": "Estadística poblacional",
                  "value": {
                    "values": [
                      1,
                      2,
                      3,
                      4
                    ]
                  }
                },
                "math_matrix": {
                  "summary": "Multiplicación de matrices",
                  "value": {
                    "a": [
                      [
                        1,
                        2
                      ],
                      [
                        3,
                        4
                      ]
                    ],
                    "b": [
                      [
                        2,
                        0
                      ],
                      [
                        1,
                        2
                      ]
                    ]
                  }
                },
                "text_convert": {
                  "summary": "Texto, base64, HEX y SHA-256",
                  "value": {
                    "text": "AppInitDev",
                    "mode": "sha256"
                  }
                },
                "data_csv-to-json": {
                  "summary": "CSV a JSON",
                  "value": {
                    "csv": "nombre,valor\nA,1\nB,2",
                    "delimiter": ","
                  }
                },
                "image_resize": {
                  "summary": "Redimensionar imagen (PHP GD)",
                  "value": {
                    "base64": "",
                    "width": 320,
                    "height": 240,
                    "format": "png"
                  }
                },
                "image_convert": {
                  "summary": "Convertir imagen (PHP GD)",
                  "value": {
                    "base64": "",
                    "format": "webp"
                  }
                },
                "audio_normalize": {
                  "summary": "Normalizar WAV PCM16",
                  "value": {
                    "base64": "",
                    "peak": 0.95
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Resultado JSON: operation y result"
          },
          "400": {
            "description": "Entrada inválida"
          },
          "404": {
            "description": "Operación no encontrada"
          },
          "405": {
            "description": "Método no permitido"
          },
          "413": {
            "description": "Cuerpo demasiado grande"
          },
          "415": {
            "description": "Content-Type incorrecto"
          },
          "422": {
            "description": "Salida fuera de límites"
          },
          "429": {
            "description": "Límite temporal"
          },
          "500": {
            "description": "Error interno"
          },
          "501": {
            "description": "Dependencia no disponible"
          },
          "503": {
            "description": "Limitador no disponible"
          }
        }
      }
    }
  }
}
