{
    "openapi": "3.1.0",
    "info": {
        "title": "Outpost 2 Map Database API",
        "version": "1.0.0",
        "description": "Maps and missions for Outpost 2. Read endpoints are anonymous and rate-limited (300/min per IP). Write endpoints need a Bearer token from /account. A map (.map) carries missions; a mission is a named scenario with one DLL per game mode."
    },
    "servers": [
        {
            "url": "https://mapsdb.outpostuniverse.org/api/v1"
        }
    ],
    "components": {
        "securitySchemes": {
            "bearer": {
                "type": "http",
                "scheme": "bearer"
            }
        },
        "parameters": {
            "page": {
                "name": "page",
                "in": "query",
                "schema": {
                    "type": "integer",
                    "minimum": 1,
                    "default": 1
                }
            },
            "per_page": {
                "name": "per_page",
                "in": "query",
                "schema": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 100,
                    "default": 50
                }
            },
            "q": {
                "name": "q",
                "in": "query",
                "description": "Free-text search",
                "schema": {
                    "type": "string"
                }
            },
            "sha": {
                "name": "sha",
                "in": "path",
                "required": true,
                "schema": {
                    "type": "string",
                    "pattern": "^[0-9a-f]{64}$"
                }
            },
            "slug": {
                "name": "slug",
                "in": "path",
                "required": true,
                "schema": {
                    "type": "string"
                }
            },
            "gameType": {
                "name": "type",
                "in": "query",
                "schema": {
                    "$ref": "#/components/schemas/GameType"
                }
            },
            "players": {
                "name": "players",
                "in": "query",
                "schema": {
                    "type": "integer"
                }
            }
        },
        "schemas": {
            "GameType": {
                "type": "string",
                "enum": [
                    "campaign",
                    "colony",
                    "tutorial",
                    "auto_demo",
                    "last_one_standing",
                    "land_rush",
                    "space_race",
                    "resource_race",
                    "midas",
                    "mixed",
                    "unknown"
                ]
            },
            "Error": {
                "type": "object",
                "properties": {
                    "error": {
                        "type": "object",
                        "properties": {
                            "code": {
                                "type": "string"
                            },
                            "message": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "Meta": {
                "type": "object",
                "properties": {
                    "page": {
                        "type": "integer"
                    },
                    "per_page": {
                        "type": "integer"
                    },
                    "total": {
                        "type": "integer"
                    },
                    "pages": {
                        "type": "integer"
                    }
                }
            },
            "PackageSummary": {
                "type": "object",
                "properties": {
                    "slug": {
                        "type": "string"
                    },
                    "title": {
                        "type": "string"
                    },
                    "summary": {
                        "type": "string"
                    },
                    "authors": {
                        "type": "string"
                    },
                    "game_type": {
                        "$ref": "#/components/schemas/GameType"
                    },
                    "players": {
                        "type": "integer"
                    },
                    "origin": {
                        "type": "string",
                        "enum": [
                            "stock",
                            "opu",
                            "community"
                        ]
                    },
                    "install_dir": {
                        "type": "string"
                    },
                    "latest_version": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "published_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date-time"
                    },
                    "thumb_url": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "page_url": {
                        "type": "string"
                    },
                    "api_url": {
                        "type": "string"
                    }
                }
            },
            "MapInfo": {
                "type": "object",
                "properties": {
                    "width": {
                        "type": "integer"
                    },
                    "height": {
                        "type": "integer"
                    },
                    "wraps": {
                        "type": "boolean"
                    },
                    "tilesets": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "preview_url": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "thumb_url": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "page_url": {
                        "type": "string"
                    }
                }
            },
            "MissionInfo": {
                "type": "object",
                "properties": {
                    "level_desc": {
                        "type": "string"
                    },
                    "type": {
                        "$ref": "#/components/schemas/GameType"
                    },
                    "players": {
                        "type": "integer"
                    },
                    "map_name": {
                        "type": "string"
                    },
                    "map_sha256": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "techtree_name": {
                        "type": "string"
                    },
                    "page_url": {
                        "type": "string"
                    }
                }
            },
            "File": {
                "type": "object",
                "properties": {
                    "path": {
                        "type": "string",
                        "description": "Install path inside the package folder (in package versions only)"
                    },
                    "name": {
                        "type": "string"
                    },
                    "kind": {
                        "type": "string",
                        "enum": [
                            "map",
                            "dll",
                            "lua",
                            "techtree",
                            "tileset",
                            "other"
                        ]
                    },
                    "size": {
                        "type": "integer"
                    },
                    "md5": {
                        "type": "string"
                    },
                    "sha256": {
                        "type": "string"
                    },
                    "stock": {
                        "type": "boolean"
                    },
                    "valid": {
                        "type": "boolean"
                    },
                    "download_url": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "null when the file may not be downloaded (stock files)"
                    },
                    "map": {
                        "$ref": "#/components/schemas/MapInfo"
                    },
                    "mission": {
                        "$ref": "#/components/schemas/MissionInfo"
                    }
                }
            },
            "Version": {
                "type": "object",
                "properties": {
                    "version": {
                        "type": "string"
                    },
                    "status": {
                        "type": "string",
                        "enum": [
                            "draft",
                            "pending_review",
                            "published",
                            "withdrawn",
                            "rejected"
                        ]
                    },
                    "published_at": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "changelog": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "install_dir": {
                        "type": "string"
                    },
                    "zip_url": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "files": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/File"
                        }
                    }
                }
            },
            "SignedManifest": {
                "type": "object",
                "properties": {
                    "format": {
                        "const": "op2mapdb-signed/1"
                    },
                    "key_id": {
                        "type": "string"
                    },
                    "manifest": {
                        "type": "string",
                        "description": "base64 of the manifest JSON (format op2mapdb-manifest/1)"
                    },
                    "signature": {
                        "type": "string",
                        "description": "base64 ed25519 signature over the decoded manifest bytes"
                    }
                }
            },
            "Mode": {
                "type": "string",
                "enum": [
                    "last_one_standing",
                    "land_rush",
                    "space_race",
                    "resource_race",
                    "midas",
                    "survival",
                    "cooperative",
                    "convoy",
                    "colony",
                    "campaign",
                    "tutorial",
                    "auto_demo",
                    "unknown"
                ]
            },
            "Mission": {
                "type": "object",
                "properties": {
                    "slug": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "kind": {
                        "type": "string",
                        "enum": [
                            "multiplayer",
                            "colony",
                            "campaign",
                            "tutorial",
                            "demo",
                            "other"
                        ]
                    },
                    "modes": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Mode"
                        }
                    },
                    "players_min": {
                        "type": "integer"
                    },
                    "players_max": {
                        "type": "integer"
                    },
                    "origin": {
                        "type": "string",
                        "enum": [
                            "stock",
                            "opu",
                            "community"
                        ]
                    },
                    "series": {
                        "type": [
                            "object",
                            "null"
                        ]
                    },
                    "map": {
                        "type": "object"
                    },
                    "dll_count": {
                        "type": "integer"
                    },
                    "updated_at": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "page_url": {
                        "type": "string"
                    },
                    "api_url": {
                        "type": "string"
                    },
                    "folders": {
                        "type": "array",
                        "description": "Published packages (folders) its DLLs install from; installing works per folder",
                        "items": {
                            "type": "object",
                            "properties": {
                                "package": {
                                    "type": "string"
                                },
                                "install_dir": {
                                    "type": "string"
                                },
                                "origin": {
                                    "type": "string"
                                },
                                "stock": {
                                    "type": "boolean"
                                }
                            }
                        }
                    },
                    "render_thumb_url": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "Thumbnail of its first game mode at start; null until drawn"
                    }
                }
            },
            "MissionDll": {
                "type": "object",
                "properties": {
                    "file": {
                        "type": "string"
                    },
                    "mode": {
                        "$ref": "#/components/schemas/Mode"
                    },
                    "variant": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "Version or remake label, e.g. 'Lua remake', 'Beta', 'v0.9'"
                    },
                    "level_desc": {
                        "type": "string"
                    },
                    "players": {
                        "type": "integer"
                    },
                    "extra_ai_players": {
                        "type": "integer"
                    },
                    "techtree_name": {
                        "type": "string"
                    },
                    "stock_menu": {
                        "type": "string"
                    },
                    "needs": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "sha256": {
                        "type": "string"
                    },
                    "download_url": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "installs_from": {
                        "type": "array",
                        "items": {
                            "type": "object"
                        }
                    },
                    "renders": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Render"
                        }
                    },
                    "resources": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/Resources"
                            },
                            {
                                "type": "null"
                            }
                        ]
                    }
                }
            },
            "Render": {
                "type": "object",
                "description": "A mission DLL drawn at start: its map with every object the DLL places on top. Made by the render server.",
                "properties": {
                    "view": {
                        "type": "string",
                        "description": "'start', or another view the render server drew"
                    },
                    "label": {
                        "type": "string"
                    },
                    "format": {
                        "type": "string",
                        "enum": [
                            "png",
                            "jpg",
                            "webp"
                        ]
                    },
                    "width": {
                        "type": "integer"
                    },
                    "height": {
                        "type": "integer"
                    },
                    "image_url": {
                        "type": "string"
                    },
                    "image_sha256": {
                        "type": "string"
                    },
                    "thumb_url": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "map_sha256": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "description": "The .map it was drawn on"
                    },
                    "tool": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "tool_version": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "updated_at": {
                        "type": "string"
                    },
                    "stats": {
                        "oneOf": [
                            {
                                "$ref": "#/components/schemas/Resources"
                            },
                            {
                                "type": "null"
                            }
                        ]
                    }
                }
            },
            "RenderJob": {
                "type": "object",
                "description": "What the render server needs for one job (docs/render-server.md)",
                "properties": {
                    "id": {
                        "type": "integer"
                    },
                    "kind": {
                        "type": "string",
                        "enum": [
                            "dll",
                            "map"
                        ]
                    },
                    "attempt": {
                        "type": "integer"
                    },
                    "lease_minutes": {
                        "type": "integer"
                    },
                    "file": {
                        "type": "object"
                    },
                    "map": {
                        "type": [
                            "object",
                            "null"
                        ]
                    },
                    "mission": {
                        "type": "object"
                    },
                    "folder": {
                        "type": [
                            "object",
                            "null"
                        ],
                        "description": "The folder the DLL installs with, and all its files"
                    },
                    "upload": {
                        "type": "object",
                        "properties": {
                            "method": {
                                "type": "string"
                            },
                            "url": {
                                "type": "string"
                            }
                        }
                    },
                    "finish_url": {
                        "type": "string"
                    }
                }
            },
            "Resources": {
                "type": "object",
                "description": "What a mission DLL places at start (counted by the render server with every player slot filled)",
                "properties": {
                    "beacons": {
                        "type": "object",
                        "properties": {
                            "common": {
                                "type": "object",
                                "properties": {
                                    "total": {
                                        "type": "integer"
                                    },
                                    "1_bar": {
                                        "type": "integer"
                                    },
                                    "2_bar": {
                                        "type": "integer"
                                    },
                                    "3_bar": {
                                        "type": "integer"
                                    },
                                    "random": {
                                        "type": "integer",
                                        "description": "yield left to the game"
                                    }
                                }
                            },
                            "rare": {
                                "type": "object",
                                "properties": {
                                    "total": {
                                        "type": "integer"
                                    },
                                    "1_bar": {
                                        "type": "integer"
                                    },
                                    "2_bar": {
                                        "type": "integer"
                                    },
                                    "3_bar": {
                                        "type": "integer"
                                    },
                                    "random": {
                                        "type": "integer",
                                        "description": "yield left to the game"
                                    }
                                }
                            }
                        }
                    },
                    "magma_vents": {
                        "type": "integer"
                    },
                    "fumaroles": {
                        "type": "integer"
                    },
                    "wrecks": {
                        "type": "integer"
                    },
                    "vehicles": {
                        "type": "integer"
                    },
                    "structures": {
                        "type": "integer"
                    },
                    "walls_tubes": {
                        "type": "integer"
                    },
                    "players": {
                        "type": "integer"
                    },
                    "human_players": {
                        "type": "integer"
                    },
                    "complete": {
                        "type": "boolean"
                    },
                    "stopped": {
                        "type": [
                            "string",
                            "null"
                        ]
                    }
                }
            }
        }
    },
    "paths": {
        "/packages": {
            "get": {
                "summary": "Search packages",
                "operationId": "listPackages",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/q"
                    },
                    {
                        "$ref": "#/components/parameters/gameType"
                    },
                    {
                        "$ref": "#/components/parameters/players"
                    },
                    {
                        "name": "origin",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "stock",
                                "opu",
                                "community"
                            ]
                        }
                    },
                    {
                        "name": "author",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "sort",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "title",
                                "newest",
                                "players"
                            ]
                        }
                    },
                    {
                        "$ref": "#/components/parameters/page"
                    },
                    {
                        "$ref": "#/components/parameters/per_page"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Packages",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/PackageSummary"
                                            }
                                        },
                                        "meta": {
                                            "$ref": "#/components/schemas/Meta"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "post": {
                "summary": "Create a package",
                "operationId": "createPackage",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "title"
                                ],
                                "properties": {
                                    "title": {
                                        "type": "string"
                                    },
                                    "summary": {
                                        "type": "string"
                                    },
                                    "description": {
                                        "type": "string"
                                    },
                                    "authors": {
                                        "type": "string"
                                    },
                                    "game_type": {
                                        "$ref": "#/components/schemas/GameType"
                                    },
                                    "players": {
                                        "type": "integer"
                                    },
                                    "install_dir": {
                                        "type": "string"
                                    },
                                    "wiki_url": {
                                        "type": "string"
                                    },
                                    "forum_url": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Created"
                    },
                    "422": {
                        "description": "Invalid",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/packages/{slug}": {
            "get": {
                "summary": "Package details with versions and the latest version's files",
                "operationId": "getPackage",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/slug"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Package"
                    },
                    "404": {
                        "description": "Not found"
                    }
                }
            },
            "post": {
                "summary": "Update package details (owner)",
                "operationId": "updatePackage",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/slug"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Updated"
                    }
                }
            }
        },
        "/packages/{slug}/versions": {
            "post": {
                "summary": "Create a version from uploaded files",
                "operationId": "createVersion",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/slug"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "version",
                                    "files"
                                ],
                                "properties": {
                                    "version": {
                                        "type": "string"
                                    },
                                    "changelog": {
                                        "type": "string"
                                    },
                                    "submit": {
                                        "type": "boolean"
                                    },
                                    "files": {
                                        "type": "array",
                                        "items": {
                                            "type": "object",
                                            "required": [
                                                "sha256"
                                            ],
                                            "properties": {
                                                "sha256": {
                                                    "type": "string"
                                                },
                                                "path": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Created; status is draft, pending_review or published"
                    }
                }
            }
        },
        "/packages/{slug}/versions/{version}": {
            "get": {
                "summary": "One version",
                "operationId": "getVersion",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/slug"
                    },
                    {
                        "name": "version",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Version",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Version"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/packages/{slug}/versions/{version}/submit": {
            "post": {
                "summary": "Submit a draft (published at once for trusted users or versions without code)",
                "operationId": "submitVersion",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/slug"
                    },
                    {
                        "name": "version",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "New status"
                    }
                }
            }
        },
        "/maps": {
            "get": {
                "summary": "Search map files",
                "operationId": "listMaps",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/q"
                    },
                    {
                        "name": "size",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "pattern": "^\\d+x\\d+$"
                        }
                    },
                    {
                        "name": "wraps",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "0",
                                "1"
                            ]
                        }
                    },
                    {
                        "name": "tileset",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "stock",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "0",
                                "1"
                            ]
                        }
                    },
                    {
                        "$ref": "#/components/parameters/page"
                    },
                    {
                        "$ref": "#/components/parameters/per_page"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Maps",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/File"
                                            }
                                        },
                                        "meta": {
                                            "$ref": "#/components/schemas/Meta"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/maps/{sha}": {
            "get": {
                "summary": "One map, with missions on it and packages containing it",
                "operationId": "getMap",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/sha"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Map"
                    }
                }
            }
        },
        "/lookup": {
            "get": {
                "summary": "Identify a file by hash",
                "operationId": "lookup",
                "parameters": [
                    {
                        "name": "md5",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "sha256",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Matching files"
                    }
                }
            }
        },
        "/files/{sha}": {
            "get": {
                "summary": "Download a file",
                "operationId": "downloadFile",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/sha"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "File bytes"
                    },
                    "403": {
                        "description": "Stock file, not downloadable"
                    }
                }
            }
        },
        "/files/{sha}/info": {
            "get": {
                "summary": "File metadata",
                "operationId": "fileInfo",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/sha"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "File"
                    }
                }
            }
        },
        "/blobs/{name}": {
            "get": {
                "summary": "Images: map previews and DLL renders (<sha256>.png, .jpg or .webp)",
                "operationId": "preview",
                "parameters": [
                    {
                        "name": "name",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "PNG"
                    }
                }
            }
        },
        "/uploads": {
            "post": {
                "summary": "Upload one file; it is inspected and stored",
                "operationId": "upload",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "requestBody": {
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "file": {
                                        "type": "string",
                                        "format": "binary"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Stored",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/File"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Stored but not valid (e.g. not a mission DLL)"
                    }
                }
            }
        },
        "/manifest": {
            "get": {
                "summary": "Signed list of installable packages",
                "operationId": "manifest",
                "responses": {
                    "200": {
                        "description": "Signed manifest",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/SignedManifest"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/manifest/key": {
            "get": {
                "summary": "The signing public key (for display; clients must pin their own copy)",
                "operationId": "manifestKey",
                "responses": {
                    "200": {
                        "description": "Key"
                    }
                }
            }
        },
        "/stats": {
            "get": {
                "summary": "Counts",
                "operationId": "stats",
                "responses": {
                    "200": {
                        "description": "Counts"
                    }
                }
            }
        },
        "/me": {
            "get": {
                "summary": "Who the token belongs to",
                "operationId": "me",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "User"
                    }
                }
            }
        },
        "/dlls": {
            "get": {
                "summary": "Search mission DLLs (one per game mode)",
                "operationId": "listDlls",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/q"
                    },
                    {
                        "$ref": "#/components/parameters/gameType"
                    },
                    {
                        "$ref": "#/components/parameters/players"
                    },
                    {
                        "name": "map",
                        "in": "query",
                        "description": "Exact map file name",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "$ref": "#/components/parameters/page"
                    },
                    {
                        "$ref": "#/components/parameters/per_page"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Missions"
                    }
                }
            }
        },
        "/dlls/{sha}": {
            "get": {
                "summary": "One mission DLL in full (DescBlock, exports, imports)",
                "operationId": "getDll",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/sha"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Mission"
                    }
                }
            }
        },
        "/missions": {
            "get": {
                "summary": "Search missions",
                "operationId": "listMissions",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/q"
                    },
                    {
                        "name": "mode",
                        "in": "query",
                        "schema": {
                            "$ref": "#/components/schemas/Mode"
                        }
                    },
                    {
                        "name": "kind",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "multiplayer",
                                "colony",
                                "campaign",
                                "tutorial",
                                "demo",
                                "other"
                            ]
                        }
                    },
                    {
                        "$ref": "#/components/parameters/players"
                    },
                    {
                        "name": "origin",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "stock",
                                "opu",
                                "community"
                            ]
                        }
                    },
                    {
                        "name": "series",
                        "in": "query",
                        "schema": {
                            "type": "string"
                        }
                    },
                    {
                        "name": "sort",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "newest",
                                "players"
                            ]
                        }
                    },
                    {
                        "$ref": "#/components/parameters/page"
                    },
                    {
                        "$ref": "#/components/parameters/per_page"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Missions",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Mission"
                                            }
                                        },
                                        "meta": {
                                            "$ref": "#/components/schemas/Meta"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/missions/{slug}": {
            "get": {
                "summary": "A mission with its DLLs (game modes) and other missions on its map. A 64-hex slug redirects to /dlls/{sha}.",
                "operationId": "getMission",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/slug"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Mission",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "allOf": [
                                                {
                                                    "$ref": "#/components/schemas/Mission"
                                                },
                                                {
                                                    "type": "object",
                                                    "properties": {
                                                        "dlls": {
                                                            "type": "array",
                                                            "items": {
                                                                "$ref": "#/components/schemas/MissionDll"
                                                            }
                                                        },
                                                        "other_missions_on_map": {
                                                            "type": "array",
                                                            "items": {
                                                                "$ref": "#/components/schemas/Mission"
                                                            }
                                                        }
                                                    }
                                                }
                                            ]
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "301": {
                        "description": "Old DLL link"
                    },
                    "404": {
                        "description": "Not found"
                    }
                }
            }
        },
        "/series": {
            "get": {
                "summary": "Series: campaigns, tutorials, demos, Exiles, Pursued",
                "operationId": "listSeries",
                "responses": {
                    "200": {
                        "description": "Series"
                    }
                }
            }
        },
        "/series/{slug}": {
            "get": {
                "summary": "A series' missions in order",
                "operationId": "getSeries",
                "parameters": [
                    {
                        "$ref": "#/components/parameters/slug"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Series"
                    }
                }
            }
        },
        "/dlls/{sha}/renders": {
            "post": {
                "summary": "Upload a render of a mission DLL (replaces the same view). Renderer, moderator or trusted token.",
                "operationId": "uploadRender",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/sha"
                    }
                ],
                "requestBody": {
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "image"
                                ],
                                "properties": {
                                    "image": {
                                        "type": "string",
                                        "format": "binary",
                                        "description": "PNG, JPEG or WebP"
                                    },
                                    "thumb": {
                                        "type": "string",
                                        "format": "binary",
                                        "description": "Optional smaller copy, same format; made here when left out"
                                    },
                                    "view": {
                                        "type": "string",
                                        "default": "start"
                                    },
                                    "label": {
                                        "type": "string"
                                    },
                                    "tool": {
                                        "type": "string"
                                    },
                                    "tool_version": {
                                        "type": "string"
                                    },
                                    "map_sha256": {
                                        "type": "string"
                                    },
                                    "stats": {
                                        "type": "string",
                                        "description": "JSON, op2imager-stats/1"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Stored",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/Render"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Not a PNG, JPEG or WebP, or out of range"
                    }
                }
            }
        },
        "/dlls/{sha}/renders/{view}": {
            "delete": {
                "summary": "Delete a render; with none left the DLL is queued to be drawn again",
                "operationId": "deleteRender",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/sha"
                    },
                    {
                        "name": "view",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "204": {
                        "description": "Deleted"
                    }
                }
            }
        },
        "/maps/{sha}/preview": {
            "post": {
                "summary": "Replace a map's preview image. Renderer or moderator token.",
                "operationId": "uploadMapPreview",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "parameters": [
                    {
                        "$ref": "#/components/parameters/sha"
                    }
                ],
                "requestBody": {
                    "content": {
                        "multipart/form-data": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "image"
                                ],
                                "properties": {
                                    "image": {
                                        "type": "string",
                                        "format": "binary",
                                        "description": "PNG, JPEG or WebP"
                                    },
                                    "thumb": {
                                        "type": "string",
                                        "format": "binary",
                                        "description": "Optional smaller copy, same format; made here when left out"
                                    },
                                    "view": {
                                        "type": "string",
                                        "default": "start"
                                    },
                                    "label": {
                                        "type": "string"
                                    },
                                    "tool": {
                                        "type": "string"
                                    },
                                    "tool_version": {
                                        "type": "string"
                                    },
                                    "map_sha256": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "201": {
                        "description": "Stored"
                    }
                }
            }
        },
        "/render-jobs": {
            "get": {
                "summary": "Render queue counts and recent failures. Renderer or moderator token.",
                "operationId": "renderStatus",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Counts"
                    }
                }
            }
        },
        "/render-jobs/claim": {
            "post": {
                "summary": "Take the next render job (leased for lease_minutes). Renderer or moderator token.",
                "operationId": "claimRenderJob",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "worker": {
                                        "type": "string"
                                    },
                                    "kinds": {
                                        "type": "array",
                                        "items": {
                                            "type": "string",
                                            "enum": [
                                                "dll",
                                                "map"
                                            ]
                                        }
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "A job",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "$ref": "#/components/schemas/RenderJob"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "204": {
                        "description": "Nothing to do"
                    }
                }
            }
        },
        "/render-jobs/{id}": {
            "post": {
                "summary": "Finish a claimed job: done (after uploading) or failed (retried up to 3 times)",
                "operationId": "finishRenderJob",
                "security": [
                    {
                        "bearer": []
                    }
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "integer"
                        }
                    }
                ],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "status"
                                ],
                                "properties": {
                                    "status": {
                                        "type": "string",
                                        "enum": [
                                            "done",
                                            "failed"
                                        ]
                                    },
                                    "error": {
                                        "type": "string"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "200": {
                        "description": "New status"
                    },
                    "409": {
                        "description": "Not running, or done with no render uploaded"
                    }
                }
            }
        }
    }
}