{
  "openapi": "3.1.0",
  "info": {
    "title": "Voxel Worlds API",
    "version": "1.0",
    "description": "An original block-building sandbox inspired by voxel games. Practice world seeds, coordinate resources, inventory conflicts and optimistic concurrency."
  },
  "servers": [
    {
      "url": "https://funapi.dev/api/voxel/v1"
    }
  ],
  "tags": [
    {
      "name": "worlds",
      "description": "procedural block worlds"
    },
    {
      "name": "players",
      "description": "survival stats and inventory"
    }
  ],
  "paths": {
    "/worlds": {
      "get": {
        "tags": [
          "worlds"
        ],
        "summary": "List worlds",
        "operationId": "vx-worlds",
        "responses": {
          "200": {
            "description": "World list",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "worlds"
        ],
        "summary": "Generate a world from a seed",
        "operationId": "vx-world-create",
        "responses": {
          "201": {
            "description": "World generated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            },
            "headers": {
              "Location": {
                "schema": {
                  "type": "string",
                  "format": "uri-reference"
                }
              }
            }
          },
          "400": {
            "description": "Invalid world",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Token required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "world-42"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "seed": {
                    "type": "integer"
                  },
                  "biome": {
                    "type": "string"
                  },
                  "difficulty": {
                    "type": "string"
                  }
                },
                "required": [
                  "name",
                  "seed",
                  "biome",
                  "difficulty"
                ],
                "additionalProperties": false
              },
              "example": {
                "name": "Redstone Ridge",
                "seed": 8675309,
                "biome": "mountains",
                "difficulty": "hard"
              }
            }
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/worlds/{id}": {
      "get": {
        "tags": [
          "worlds"
        ],
        "summary": "Get a world",
        "operationId": "vx-world",
        "responses": {
          "200": {
            "description": "World",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "404": {
            "description": "Unknown world",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 1
          }
        ]
      }
    },
    "/worlds/{id}/blocks/{x}/{y}/{z}": {
      "get": {
        "tags": [
          "worlds"
        ],
        "summary": "Inspect a block at coordinates",
        "operationId": "vx-block",
        "responses": {
          "200": {
            "description": "Block",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "404": {
            "description": "World not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 1
          },
          {
            "name": "x",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 4
          },
          {
            "name": "y",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 4
          },
          {
            "name": "z",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            },
            "example": 4
          }
        ]
      }
    },
    "/players": {
      "get": {
        "tags": [
          "players"
        ],
        "summary": "List players",
        "operationId": "vx-players",
        "responses": {
          "200": {
            "description": "Players",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/players/{id}/inventory": {
      "post": {
        "tags": [
          "players"
        ],
        "summary": "Add an inventory item (409 on duplicate)",
        "operationId": "vx-inventory",
        "responses": {
          "200": {
            "description": "Item added",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "404": {
            "description": "Player missing",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Already owned",
            "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": {
                  "item": {
                    "type": "string"
                  }
                },
                "required": [
                  "item"
                ],
                "additionalProperties": false
              },
              "example": {
                "item": "diamond_pickaxe"
              }
            }
          }
        },
        "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
      }
    }
  }
}
