{
  "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",
                  "properties": {
                    "total": {
                      "type": "number"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "number"
                          },
                          "name": {
                            "type": "string"
                          },
                          "element": {
                            "type": "string"
                          },
                          "power": {
                            "type": "number"
                          },
                          "rank": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "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",
                  "properties": {
                    "id": {
                      "type": "number"
                    },
                    "name": {
                      "type": "string"
                    },
                    "element": {
                      "type": "string"
                    },
                    "power": {
                      "type": "number"
                    },
                    "rank": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Missing fighter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "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",
                  "properties": {
                    "id": {
                      "type": "number"
                    },
                    "name": {
                      "type": "string"
                    },
                    "element": {
                      "type": "string"
                    },
                    "power": {
                      "type": "number"
                    },
                    "rank": {
                      "type": "string"
                    },
                    "form": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Invalid multiplier",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "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"
                  }
                }
              },
              "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",
                  "properties": {
                    "id": {
                      "type": "number"
                    },
                    "fighterA": {
                      "type": "string"
                    },
                    "fighterB": {
                      "type": "string"
                    },
                    "winner": {
                      "type": "string"
                    },
                    "turns": {
                      "type": "number"
                    }
                  }
                }
              }
            },
            "headers": {
              "Location": {
                "schema": {
                  "type": "string",
                  "format": "uri-reference"
                }
              }
            }
          },
          "400": {
            "description": "Invalid fighters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "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": "number"
                  },
                  "fighterBId": {
                    "type": "number"
                  }
                }
              },
              "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",
                  "properties": {
                    "total": {
                      "type": "number"
                    },
                    "data": {
                      "type": "array"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "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
      }
    }
  }
}
