nquest/api/openapi.yaml

463 lines
9.8 KiB
YAML
Raw Normal View History

2023-11-01 23:21:12 +03:00
openapi: "3.1.0"
2023-11-01 23:21:12 +03:00
info:
version: 1.0.0
title: nQuest
2023-11-01 23:21:12 +03:00
servers:
- url: /api
2023-11-01 23:21:12 +03:00
paths:
# User routes
2023-11-01 23:21:12 +03:00
/user:
get:
responses:
200:
$ref: "#/components/responses/userResponse"
2023-11-01 23:21:12 +03:00
403:
$ref: "#/components/responses/errorResponse"
2023-11-01 23:21:12 +03:00
/user/login:
post:
security: []
requestBody:
2024-01-28 22:19:41 +03:00
content:
application/json:
schema:
type: object
properties:
email:
type: string
password:
type: string
required: [email, password]
2023-11-01 23:21:12 +03:00
responses:
200:
$ref: "#/components/responses/userResponse"
2023-11-01 23:21:12 +03:00
400:
$ref: "#/components/responses/errorResponse"
2023-11-01 23:21:12 +03:00
/user/register:
post:
security: []
requestBody:
2024-01-28 22:19:41 +03:00
content:
application/json:
schema:
type: object
properties:
username:
type: string
email:
type: string
password:
type: string
password2:
type: string
required: [username, email, password, password2]
2023-11-01 23:21:12 +03:00
responses:
200:
$ref: "#/components/responses/userResponse"
2023-11-01 23:21:12 +03:00
400:
$ref: "#/components/responses/errorResponse"
2023-11-01 23:21:12 +03:00
/user/logout:
post:
responses:
204:
description: "success logout"
400:
$ref: "#/components/responses/errorResponse"
2024-01-05 03:50:33 +03:00
# Game routes
2024-01-05 03:50:33 +03:00
/games:
2023-11-01 23:21:12 +03:00
get:
responses:
200:
$ref: "#/components/responses/gameListResponse"
2024-01-05 03:50:33 +03:00
/engine/{uid}:
2023-11-01 23:21:12 +03:00
get:
2024-01-05 03:50:33 +03:00
operationId: gameEngine
2023-11-01 23:21:12 +03:00
parameters:
2024-01-05 03:50:33 +03:00
- name: uid
in: path
2023-11-01 23:21:12 +03:00
required: true
schema:
type: string
format: uuid
responses:
200:
$ref: "#/components/responses/taskResponse"
2024-01-05 03:50:33 +03:00
/engine/{uid}/code:
post:
2024-01-05 03:50:33 +03:00
operationId: enterCode
parameters:
2024-01-05 03:50:33 +03:00
- name: uid
in: path
required: true
schema:
type: string
format: uuid
2024-01-20 21:37:49 +03:00
requestBody:
content:
2024-01-28 22:19:41 +03:00
application/json:
2024-01-20 21:37:49 +03:00
schema:
2024-01-28 22:19:41 +03:00
type: object
properties:
code:
type: string
required:
- code
2024-01-20 21:37:49 +03:00
responses:
200:
2024-01-28 22:19:41 +03:00
$ref: "#/components/responses/taskResponse"
2024-01-20 21:37:49 +03:00
/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":
2024-01-20 21:37:49 +03:00
schema:
type: string
format: binary
2024-01-28 22:19:41 +03:00
# Admin routes
/admin/file/{quest}/upload:
2024-01-28 22:19:41 +03:00
post:
operationId: adminUploadFile
security:
- cookieAuth: [creator, admin]
parameters:
- name: quest
in: path
required: true
schema:
type: string
format: uuid
2024-01-28 22:19:41 +03:00
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:
2024-01-28 22:19:41 +03:00
operationId: adminListGames
responses:
200:
$ref: "#/components/responses/gameListResponse"
post:
2024-01-28 22:19:41 +03:00
operationId: adminEditGame
security:
- cookieAuth: [creator, admin]
requestBody:
2024-01-28 22:19:41 +03:00
content:
application/json:
schema:
$ref: "#/components/schemas/gameEdit"
responses:
200:
$ref: "#/components/responses/gameAdminResponse"
/admin/games/{uid}:
get:
2024-01-28 22:19:41 +03:00
operationId: adminGetGame
parameters:
- name: uid
in: path
required: true
schema:
type: string
format: uuid
security:
- cookieAuth: [creator, admin]
responses:
200:
$ref: "#/components/responses/gameAdminResponse"
2024-01-28 22:19:41 +03:00
2023-11-01 23:21:12 +03:00
components:
schemas:
2024-01-05 03:50:33 +03:00
userView:
2023-11-01 23:21:12 +03:00
type: object
properties:
id:
type: string
format: uuid
2024-01-05 03:50:33 +03:00
username:
2023-11-01 23:21:12 +03:00
type: string
2024-01-21 02:20:59 +03:00
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
2024-01-05 03:50:33 +03:00
gameView:
2023-11-01 23:21:12 +03:00
type: object
properties:
2024-01-05 03:50:33 +03:00
id:
type: string
format: uuid
visible:
type: boolean
2024-01-05 03:50:33 +03:00
title:
type: string
description:
2023-11-01 23:21:12 +03:00
type: string
2024-01-05 03:50:33 +03:00
type:
$ref: "#/components/schemas/gameType"
points:
type: integer
taskCount:
type: integer
createdAt:
type: string
authors:
type: array
items:
$ref: "#/components/schemas/userView"
2024-01-20 21:37:49 +03:00
icon:
type: string
format: uuid
2024-01-05 03:50:33 +03:00
required:
- id
- title
- description
- type
- points
- taskCount
- createdAt
- authors
2024-01-05 03:50:33 +03:00
taskView:
2023-11-01 23:21:12 +03:00
type: object
properties:
message:
type: string
enum:
- ok_code
- invalid_code
- old_code
- next_level
- game_complete
2024-01-05 03:50:33 +03:00
title:
2023-11-01 23:21:12 +03:00
type: string
2024-01-05 03:50:33 +03:00
text:
type: string
codes:
type: array
items:
$ref: "#/components/schemas/codeView"
2024-01-05 03:50:33 +03:00
required:
- title
- text
- codes
codeView:
2023-11-01 23:21:12 +03:00
type: object
properties:
2024-01-05 03:50:33 +03:00
description:
2023-11-01 23:21:12 +03:00
type: string
2024-01-05 03:50:33 +03:00
code:
type: string
gameEdit:
type: object
properties:
id:
type: string
format: uuid
visible:
type: boolean
title:
type: string
description:
type: string
2024-01-05 03:50:33 +03:00
type:
$ref: "#/components/schemas/gameType"
tasks:
type: array
items:
2024-01-05 03:50:33 +03:00
$ref: "#/components/schemas/taskEdit"
points:
type: integer
2024-01-20 21:37:49 +03:00
icon:
type: string
format: uuid
required:
- visible
- title
- description
2024-01-05 03:50:33 +03:00
- type
- tasks
- points
taskEdit:
2023-11-19 22:54:54 +03:00
type: object
properties:
id:
type: string
format: uuid
2023-11-19 22:54:54 +03:00
title:
type: string
2024-01-05 03:50:33 +03:00
text:
type: string
codes:
type: array
items:
$ref: "#/components/schemas/codeEdit"
2024-01-05 03:50:33 +03:00
required:
- title
- text
- codes
codeEdit:
type: object
properties:
id:
type: string
format: uuid
2024-01-05 03:50:33 +03:00
description:
type: string
code:
2023-11-19 22:54:54 +03:00
type: string
2024-01-05 03:50:33 +03:00
required:
- 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
2023-11-01 23:21:12 +03:00
responses:
userResponse:
description: ""
2023-11-01 23:21:12 +03:00
content:
2024-01-28 22:19:41 +03:00
application/json:
2023-11-01 23:21:12 +03:00
schema:
2024-01-21 02:20:59 +03:00
$ref: "#/components/schemas/userView"
2023-11-01 23:21:12 +03:00
errorResponse:
description: ""
2023-11-01 23:21:12 +03:00
content:
2024-01-28 22:19:41 +03:00
application/json:
2023-11-01 23:21:12 +03:00
schema:
type: object
properties:
code:
type: integer
message:
type: string
required: [code, message]
gameListResponse:
description: ""
content:
2024-01-28 22:19:41 +03:00
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/gameView"
gameResponse:
description: ""
content:
2024-01-28 22:19:41 +03:00
application/json:
schema:
$ref: "#/components/schemas/gameView"
gameAdminResponse:
description: ""
content:
2024-01-28 22:19:41 +03:00
application/json:
schema:
$ref: "#/components/schemas/gameEdit"
2024-01-05 03:50:33 +03:00
taskResponse:
description: ""
2023-11-19 22:54:54 +03:00
content:
2024-01-28 22:19:41 +03:00
application/json:
2023-11-19 22:54:54 +03:00
schema:
2024-01-05 03:50:33 +03:00
$ref: "#/components/schemas/taskView"
2024-01-20 21:37:49 +03:00
uploadResponse:
description: ""
2024-01-20 21:37:49 +03:00
content:
2024-01-28 22:19:41 +03:00
application/json:
2024-01-20 21:37:49 +03:00
schema:
type: object
properties:
uuid:
type: string
format: uuid
required:
- uuid
filesListResponse:
description: ""
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/fileItem"
2023-11-01 23:21:12 +03:00
securitySchemes:
cookieAuth:
type: apiKey
in: cookie
name: session
2023-11-01 23:21:12 +03:00
security:
- cookieAuth: []