{
  "openapi": "3.0.4",
  "info": {
    "title": "YARG.Online.Lobbies HTTP API",
    "description": "Hosting and discovery for YARG multiplayer lobbies.",
    "version": "v0"
  },
  "servers": [
    {
      "url": "http://yarg-online.matt.you/"
    }
  ],
  "paths": {
    "/api/v1/auth/dev": {
      "post": {
        "tags": [
          "Auth"
        ],
        "summary": "Issue a dev auth token.",
        "operationId": "AuthDev",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DevAuthRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DevAuthResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/HttpValidationProblemDetails"
                }
              }
            }
          },
          "426": {
            "description": "Upgrade Required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientVersionError"
                }
              }
            }
          },
          "429": {
            "description": "Too Many Requests",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/lobbies/{lobbyId}/game-finished": {
      "post": {
        "tags": [
          "GameLifecycle"
        ],
        "summary": "Mark a lobby's game as finished and return it to song select.",
        "operationId": "FinishGame",
        "parameters": [
          {
            "name": "lobbyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/lobbies/{lobbyId}/song-started": {
      "post": {
        "tags": [
          "GameLifecycle"
        ],
        "summary": "Record the wall-clock start time and duration of the song now playing.",
        "operationId": "SongStarted",
        "parameters": [
          {
            "name": "lobbyId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SongStartedRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "No Content"
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/ProblemDetails"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ClientVersionError": {
        "required": [
          "error",
          "minVersion"
        ],
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "nullable": true
          },
          "minVersion": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "DevAuthRequest": {
        "required": [
          "name"
        ],
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "clientVersion": {
            "type": "string",
            "default": null,
            "nullable": true
          }
        }
      },
      "DevAuthResponse": {
        "required": [
          "token",
          "userId",
          "displayName",
          "expiresAt"
        ],
        "type": "object",
        "properties": {
          "token": {
            "type": "string",
            "nullable": true
          },
          "userId": {
            "type": "string",
            "nullable": true
          },
          "displayName": {
            "type": "string",
            "nullable": true
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "HttpValidationProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          },
          "errors": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        }
      },
      "ProblemDetails": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "nullable": true
          },
          "title": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "nullable": true
          },
          "detail": {
            "type": "string",
            "nullable": true
          },
          "instance": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "SongStartedRequest": {
        "required": [
          "songOriginUtcMs",
          "durationMs"
        ],
        "type": "object",
        "properties": {
          "songOriginUtcMs": {
            "type": "integer",
            "format": "int64"
          },
          "durationMs": {
            "type": "integer",
            "format": "int32"
          }
        }
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "description": "JWT issued by POST /api/v1/auth/dev. Send as `Authorization: Bearer <token>`.",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  },
  "tags": [
    {
      "name": "Auth"
    },
    {
      "name": "GameLifecycle"
    }
  ]
}