{
  "openapi": "3.1.0",
  "info": {
    "title": "Dragon Ball API",
    "version": "1.0",
    "description": "Explore Dragon Ball fighters and transformations, then run authenticated tournament battles with deterministic sandbox results."
  },
  "servers": [
    {
      "url": "https://funapi.dev/api/dragonball/v1"
    }
  ],
  "tags": [
    {
      "name": "fighters",
      "description": "warriors and power levels"
    },
    {
      "name": "tournaments",
      "description": "battle simulation"
    }
  ],
  "paths": {
    "/fighters": {
      "get": {
        "tags": [
          "fighters"
        ],
        "summary": "List fighters by race or minimum power",
        "operationId": "db-fighters",
        "responses": {
          "200": {
            "description": "Fighter list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "race",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "Saiyan"
          },
          {
            "name": "minPower",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 8000
          }
        ]
      }
    },
    "/fighters/{id}": {
      "get": {
        "tags": [
          "fighters"
        ],
        "summary": "Get one fighter",
        "operationId": "db-fighter",
        "responses": {
          "200": {
            "description": "Fighter",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "404": {
            "description": "Unknown 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}/transformations": {
      "get": {
        "tags": [
          "fighters"
        ],
        "summary": "List a fighter’s transformations",
        "operationId": "db-transformations",
        "responses": {
          "200": {
            "description": "Transformations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "404": {
            "description": "Unknown 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}/power-up": {
      "post": {
        "tags": [
          "fighters"
        ],
        "summary": "Increase a fighter’s power level",
        "operationId": "db-power-up",
        "responses": {
          "200": {
            "description": "Power increased",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "422": {
            "description": "Invalid amount",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 3
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "amount": {
                    "type": "integer"
                  }
                },
                "required": [
                  "amount"
                ],
                "additionalProperties": false
              },
              "example": {
                "amount": 500
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/tournaments": {
      "post": {
        "tags": [
          "tournaments"
        ],
        "summary": "Resolve a tournament match",
        "operationId": "db-tournament",
        "responses": {
          "201": {
            "description": "Match resolved",
            "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"
                }
              }
            }
          },
          "409": {
            "description": "Same fighter",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "db-match-1"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "fighterAId": {
                    "type": "integer"
                  },
                  "fighterBId": {
                    "type": "integer"
                  },
                  "arena": {
                    "type": "string"
                  }
                },
                "required": [
                  "fighterAId",
                  "fighterBId",
                  "arena"
                ],
                "additionalProperties": false
              },
              "example": {
                "fighterAId": 1,
                "fighterBId": 4,
                "arena": "World Martial Arts Tournament"
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/tournaments/{id}": {
      "get": {
        "tags": [
          "tournaments"
        ],
        "summary": "Get a tournament match",
        "operationId": "db-tournament-get",
        "responses": {
          "200": {
            "description": "Match",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "404": {
            "description": "Unknown match",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 1
          }
        ]
      }
    }
  },
  "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
      }
    }
  }
}
