openapi: "3.1.0" info: version: 1.0.0 title: nQuest servers: - url: /api paths: # User routes /user: get: responses: 200: $ref: "#/components/responses/userResponse" 403: $ref: "#/components/responses/errorResponse" /user/login: post: security: [] requestBody: content: application/json: schema: type: object properties: email: type: string password: type: string required: [email, password] responses: 200: $ref: "#/components/responses/userResponse" 400: $ref: "#/components/responses/errorResponse" /user/register: post: security: [] requestBody: content: application/json: schema: type: object properties: username: type: string email: type: string password: type: string password2: type: string required: [username, email, password, password2] responses: 200: $ref: "#/components/responses/userResponse" 400: $ref: "#/components/responses/errorResponse" /user/logout: post: responses: 204: description: "success logout" 400: $ref: "#/components/responses/errorResponse" # Game routes /games: get: responses: 200: $ref: "#/components/responses/gameListResponse" /engine/{uid}: get: operationId: gameEngine parameters: - name: uid in: path required: true schema: type: string format: uuid responses: 200: $ref: "#/components/responses/taskResponse" /engine/{uid}/code: post: operationId: enterCode parameters: - name: uid in: path required: true schema: type: string format: uuid requestBody: content: application/json: schema: type: object properties: code: type: string required: - code responses: 200: $ref: "#/components/responses/taskResponse" /file/{uid}: get: operationId: getFile parameters: - name: uid in: path required: true schema: type: string format: uuid responses: 200: description: file content: "application/octet-stream": schema: type: string format: binary # Admin routes /admin/file/{quest}/upload: post: operationId: adminUploadFile security: - cookieAuth: [creator, admin] parameters: - name: quest in: path required: true schema: type: string format: uuid requestBody: content: multipart/form-data: schema: type: object properties: file: type: string format: binary responses: 200: $ref: "#/components/responses/uploadResponse" /admin/file/{quest}: get: operationId: adminListFiles security: - cookieAuth: [creator, admin] parameters: - name: quest in: path required: true schema: type: string format: uuid responses: 200: $ref: "#/components/responses/filesListResponse" /admin/games: get: operationId: adminListGames responses: 200: $ref: "#/components/responses/gameListResponse" post: operationId: adminEditGame security: - cookieAuth: [creator, admin] requestBody: content: application/json: schema: $ref: "#/components/schemas/gameEdit" responses: 200: $ref: "#/components/responses/gameAdminResponse" /admin/games/{uid}: get: operationId: adminGetGame parameters: - name: uid in: path required: true schema: type: string format: uuid security: - cookieAuth: [creator, admin] responses: 200: $ref: "#/components/responses/gameAdminResponse" components: schemas: userView: type: object properties: id: type: string format: uuid username: type: string email: type: string experience: type: integer level: type: integer expToCurrentLevel: type: integer expToNextLevel: type: integer games: type: array items: $ref: "#/components/schemas/gameView" role: type: string enum: - user - creator - admin required: - id - username - email - experience - level - expToCurrentLevel - expToNextLevel - games - role gameView: type: object properties: id: type: string format: uuid visible: type: boolean title: type: string description: type: string type: $ref: "#/components/schemas/gameType" points: type: integer taskCount: type: integer createdAt: type: string authors: type: array items: $ref: "#/components/schemas/userView" icon: type: string format: uuid required: - id - title - description - type - points - taskCount - createdAt - authors - icon taskView: type: object properties: message: type: string enum: - ok_code - invalid_code - old_code - next_level - game_complete title: type: string text: type: string codes: type: array items: $ref: "#/components/schemas/codeView" required: - title - text - codes codeView: type: object properties: description: type: string code: type: string required: - description gameEdit: type: object properties: id: type: string format: uuid visible: type: boolean title: type: string description: type: string type: $ref: "#/components/schemas/gameType" tasks: type: array items: $ref: "#/components/schemas/taskEdit" points: type: integer icon: type: string format: uuid required: - visible - title - description - type - tasks - points taskEdit: type: object properties: id: type: string format: uuid title: type: string text: type: string codes: type: array items: $ref: "#/components/schemas/codeEdit" required: - title - text - codes codeEdit: type: object properties: id: type: string format: uuid description: type: string code: type: string required: - description - code gameType: type: string enum: - virtual - city fileItem: type: object properties: id: type: string format: uuid originalName: type: string size: type: integer required: - id - originalName - size responses: userResponse: description: "" content: application/json: schema: $ref: "#/components/schemas/userView" errorResponse: description: "" content: application/json: schema: type: object properties: code: type: integer message: type: string required: [code, message] gameListResponse: description: "" content: application/json: schema: type: array items: $ref: "#/components/schemas/gameView" gameResponse: description: "" content: application/json: schema: $ref: "#/components/schemas/gameView" gameAdminResponse: description: "" content: application/json: schema: $ref: "#/components/schemas/gameEdit" taskResponse: description: "" content: application/json: schema: $ref: "#/components/schemas/taskView" uploadResponse: description: "" content: application/json: schema: type: object properties: uuid: type: string format: uuid required: - uuid filesListResponse: description: "" content: application/json: schema: type: array items: $ref: "#/components/schemas/fileItem" securitySchemes: cookieAuth: type: apiKey in: cookie name: session security: - cookieAuth: []