{
  "openapi": "3.1.0",
  "info": {
    "title": "Retro Quest API",
    "version": "1.0",
    "description": "An original 16-bit RPG world for testing quests, inventory, saves and state transitions."
  },
  "servers": [
    {
      "url": "https://funapi.dev/api/retro/v1"
    }
  ],
  "tags": [
    {
      "name": "heroes",
      "description": "pixel adventurers"
    },
    {
      "name": "quests",
      "description": "bugs disguised as monsters"
    }
  ],
  "paths": {
    "/heroes": {
      "get": {
        "tags": [
          "heroes"
        ],
        "summary": "List pixel heroes",
        "operationId": "rq-heroes",
        "responses": {
          "200": {
            "description": "Heroes",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "heroes"
        ],
        "summary": "Create a hero",
        "operationId": "rq-hero",
        "responses": {
          "201": {
            "description": "Hero created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            },
            "headers": {
              "Location": {
                "schema": {
                  "type": "string",
                  "format": "uri-reference"
                }
              }
            }
          },
          "400": {
            "description": "Name required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "class": {
                    "type": "string"
                  }
                },
                "required": [
                  "name",
                  "class"
                ],
                "additionalProperties": false
              },
              "example": {
                "name": "Lin the Linter",
                "class": "ranger"
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/quests": {
      "get": {
        "tags": [
          "quests"
        ],
        "summary": "List quests by status",
        "operationId": "rq-quests",
        "responses": {
          "200": {
            "description": "Quests",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "open"
          }
        ]
      }
    },
    "/quests/{id}/accept": {
      "post": {
        "tags": [
          "quests"
        ],
        "summary": "Accept a quest (409 if already accepted)",
        "operationId": "rq-accept",
        "responses": {
          "200": {
            "description": "Quest accepted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "409": {
            "description": "Wrong state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 1
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "heroId": {
                    "type": "integer"
                  }
                },
                "required": [
                  "heroId"
                ],
                "additionalProperties": false
              },
              "example": {
                "heroId": 1
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/quests/{id}/complete": {
      "post": {
        "tags": [
          "quests"
        ],
        "summary": "Complete an active quest",
        "operationId": "rq-complete",
        "responses": {
          "200": {
            "description": "Quest complete",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "409": {
            "description": "Not active",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 1
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    }
  },
  "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
      }
    }
  }
}
