{
  "openapi": "3.1.1",
  "info": {
    "title": "Piconet coordinator: public API",
    "description": "What anyone may read: the service's status (what released launchers read; fields are only ever added) and its health.",
    "version": "1"
  },
  "servers": [
    {
      "url": "http://play.piconet.live/"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "Whether the coordinator answers: \"ok\" (the host's checks).",
        "operationId": "health",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/status": {
      "get": {
        "tags": [
          "Public"
        ],
        "summary": "The service now: players online, lobbies, matches starting, races running, relays (what launchers read).",
        "operationId": "status",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceStatus"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CustomMachine": {
        "required": [
          "body",
          "cockpit",
          "booster",
          "pilot"
        ],
        "type": "object",
        "properties": {
          "body": {
            "type": "integer",
            "format": "int32"
          },
          "cockpit": {
            "type": "integer",
            "format": "int32"
          },
          "booster": {
            "type": "integer",
            "format": "int32"
          },
          "pilot": {
            "type": "integer",
            "format": "int32"
          },
          "colors": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "type": "integer",
              "format": "uint32"
            }
          }
        }
      },
      "FormingMatchView": {
        "required": [
          "id",
          "players",
          "stage"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "players": {
            "type": "integer",
            "format": "int32"
          },
          "stage": {
            "type": "string"
          }
        }
      },
      "LineBuildView": {
        "required": [
          "build",
          "line"
        ],
        "type": "object",
        "properties": {
          "build": {
            "type": "string"
          },
          "line": {
            "type": "string"
          },
          "label": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "LobbyBuildView": {
        "required": [
          "build",
          "players"
        ],
        "type": "object",
        "properties": {
          "build": {
            "type": "string"
          },
          "players": {
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "LobbyView": {
        "required": [
          "id",
          "players",
          "capacity",
          "votingOpen",
          "startVotes"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "players": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RacerView"
            }
          },
          "capacity": {
            "type": "integer",
            "format": "int32"
          },
          "votingOpen": {
            "type": "boolean"
          },
          "startVotes": {
            "type": "integer",
            "format": "int32"
          },
          "stage": {
            "type": "string",
            "default": "forming"
          },
          "raceId": {
            "type": [
              "null",
              "string"
            ]
          },
          "racing": {
            "type": "integer",
            "format": "int32",
            "default": 0
          },
          "build": {
            "type": [
              "null",
              "string"
            ]
          },
          "builds": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "$ref": "#/components/schemas/LobbyBuildView"
            }
          },
          "line": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "RaceSnapshot": {
        "required": [
          "frame",
          "localSeat",
          "racers"
        ],
        "type": "object",
        "properties": {
          "frame": {
            "type": "integer",
            "format": "int32"
          },
          "localSeat": {
            "type": "integer",
            "format": "int32"
          },
          "racers": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RacerLive"
            }
          }
        }
      },
      "RaceView": {
        "required": [
          "id",
          "relay",
          "region",
          "course",
          "courseName",
          "laps",
          "players",
          "cpuRacers",
          "started"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "relay": {
            "type": "string"
          },
          "region": {
            "type": "string"
          },
          "course": {
            "type": "integer",
            "format": "int32"
          },
          "courseName": {
            "type": "string"
          },
          "laps": {
            "type": "integer",
            "format": "int32"
          },
          "players": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RacerView"
            }
          },
          "cpuRacers": {
            "type": "integer",
            "format": "int32"
          },
          "started": {
            "type": "string",
            "format": "date-time"
          },
          "live": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/RaceSnapshot"
              }
            ]
          }
        }
      },
      "RacerLive": {
        "required": [
          "seat",
          "rank",
          "lap",
          "lapMs",
          "totalMs",
          "bestLapMs",
          "speed",
          "energy",
          "maxEnergy",
          "kos",
          "topSpeed",
          "state",
          "x",
          "y",
          "z"
        ],
        "type": "object",
        "properties": {
          "seat": {
            "type": "integer",
            "format": "int32"
          },
          "rank": {
            "type": "integer",
            "format": "int32"
          },
          "lap": {
            "type": "integer",
            "format": "int32"
          },
          "lapMs": {
            "type": "integer",
            "format": "int32"
          },
          "totalMs": {
            "type": "integer",
            "format": "int32"
          },
          "bestLapMs": {
            "type": [
              "null",
              "integer"
            ],
            "format": "int32"
          },
          "speed": {
            "type": "number",
            "format": "float"
          },
          "energy": {
            "type": "number",
            "format": "float"
          },
          "maxEnergy": {
            "type": "number",
            "format": "float"
          },
          "kos": {
            "type": "integer",
            "format": "int32"
          },
          "topSpeed": {
            "type": "number",
            "format": "float"
          },
          "state": {
            "type": "string"
          },
          "x": {
            "type": "number",
            "format": "float"
          },
          "y": {
            "type": "number",
            "format": "float"
          },
          "z": {
            "type": "number",
            "format": "float"
          },
          "distance": {
            "type": "number",
            "format": "float",
            "default": 0
          }
        }
      },
      "RacerView": {
        "required": [
          "name",
          "machine",
          "color"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "machine": {
            "type": "integer",
            "format": "int32"
          },
          "color": {
            "type": [
              "null",
              "string"
            ]
          },
          "tag": {
            "type": [
              "null",
              "string"
            ]
          },
          "custom": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/CustomMachine"
              }
            ]
          }
        }
      },
      "RecentNotice": {
        "required": [
          "id",
          "level",
          "text",
          "time"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "level": {
            "type": "string"
          },
          "text": {
            "type": "string"
          },
          "time": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "RelayView": {
        "required": [
          "id",
          "region",
          "races",
          "players"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "region": {
            "type": "string"
          },
          "races": {
            "type": [
              "null",
              "integer"
            ],
            "format": "int32"
          },
          "players": {
            "type": [
              "null",
              "integer"
            ],
            "format": "int32"
          },
          "maxRaces": {
            "type": [
              "null",
              "integer"
            ],
            "format": "int32"
          },
          "state": {
            "type": [
              "null",
              "string"
            ]
          },
          "address": {
            "type": [
              "null",
              "string"
            ]
          },
          "size": {
            "type": [
              "null",
              "string"
            ]
          },
          "idleUntil": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "addressUntil": {
            "type": [
              "null",
              "string"
            ],
            "format": "date-time"
          },
          "error": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "ServiceStatus": {
        "required": [
          "name",
          "time",
          "playersOnline",
          "lobbies",
          "starting",
          "races",
          "relays"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "time": {
            "type": "string",
            "format": "date-time"
          },
          "playersOnline": {
            "type": "integer",
            "format": "int32"
          },
          "lobbies": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/LobbyView"
            }
          },
          "starting": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FormingMatchView"
            }
          },
          "races": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RaceView"
            }
          },
          "relays": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RelayView"
            }
          },
          "statPack": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/StatPackName"
              }
            ]
          },
          "packSetting": {
            "type": [
              "null",
              "string"
            ]
          },
          "together": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/TogetherView"
              }
            ]
          },
          "togetherSetting": {
            "type": [
              "null",
              "string"
            ]
          },
          "togetherFault": {
            "type": [
              "null",
              "string"
            ]
          },
          "togetherFiles": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "$ref": "#/components/schemas/TogetherFileView"
            }
          },
          "lineBuilds": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "$ref": "#/components/schemas/LineBuildView"
            }
          },
          "lineBuildsFault": {
            "type": [
              "null",
              "string"
            ]
          },
          "motd": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/RecentNotice"
              }
            ]
          }
        }
      },
      "StatPackName": {
        "required": [
          "name",
          "fingerprint"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "fingerprint": {
            "type": "string"
          },
          "author": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "TogetherBuildView": {
        "required": [
          "build"
        ],
        "type": "object",
        "properties": {
          "build": {
            "type": "string"
          },
          "label": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "TogetherFileView": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "fingerprint": {
            "type": [
              "null",
              "string"
            ]
          }
        }
      },
      "TogetherView": {
        "required": [
          "name",
          "builds",
          "fingerprint"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "builds": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TogetherBuildView"
            }
          },
          "fingerprint": {
            "type": "string"
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Public"
    }
  ]
}