{
  "openapi": "3.1.0",
  "info": {
    "title": "Anime Tournament API",
    "version": "1.0",
    "description": "An original anime-style tournament with transformations, rankings and deliberately dramatic power scaling."
  },
  "servers": [
    {
      "url": "https://funapi.dev/api/anime/v1"
    }
  ],
  "tags": [
    {
      "name": "fighters",
      "description": "heroes and rivals"
    },
    {
      "name": "matches",
      "description": "tournament battles"
    }
  ],
  "paths": {
    "/fighters": {
      "get": {
        "tags": [
          "fighters"
        ],
        "summary": "List fighters, filter by rank",
        "operationId": "an-fighters",
        "responses": {
          "200": {
            "description": "Fighters",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "rank",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "S"
          }
        ]
      }
    },
    "/fighters/{id}": {
      "get": {
        "tags": [
          "fighters"
        ],
        "summary": "Get fighter power profile",
        "operationId": "an-fighter",
        "responses": {
          "200": {
            "description": "Fighter",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "404": {
            "description": "Missing fighter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 1
          }
        ]
      }
    },
    "/fighters/{id}/transform": {
      "post": {
        "tags": [
          "fighters"
        ],
        "summary": "Transform a fighter and increase power",
        "operationId": "an-transform",
        "responses": {
          "200": {
            "description": "Transformed",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "422": {
            "description": "Invalid multiplier",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 2
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "form": {
                    "type": "string"
                  },
                  "multiplier": {
                    "type": "number"
                  }
                },
                "required": [
                  "form",
                  "multiplier"
                ],
                "additionalProperties": false
              },
              "example": {
                "form": "Ultra Debug Mode",
                "multiplier": 1.5
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/matches": {
      "post": {
        "tags": [
          "matches"
        ],
        "summary": "Run a deterministic tournament match",
        "operationId": "an-match",
        "responses": {
          "201": {
            "description": "Match complete",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            },
            "headers": {
              "Location": {
                "schema": {
                  "type": "string",
                  "format": "uri-reference"
                }
              }
            }
          },
          "400": {
            "description": "Invalid fighters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "final-1"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "fighterAId": {
                    "type": "integer"
                  },
                  "fighterBId": {
                    "type": "integer"
                  }
                },
                "required": [
                  "fighterAId",
                  "fighterBId"
                ],
                "additionalProperties": false
              },
              "example": {
                "fighterAId": 1,
                "fighterBId": 2
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      },
      "get": {
        "tags": [
          "matches"
        ],
        "summary": "List match history",
        "operationId": "an-matches",
        "responses": {
          "200": {
            "description": "Matches",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Use qa-admin-token / qa-viewer-token, or a JWT from POST /auth/v1/login."
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Cargo demo key: cargo-key-123."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error",
          "message"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "requestId": {
            "type": "string"
          }
        },
        "additionalProperties": true
      }
    }
  }
}
