nquest/api/openapi.yaml

527 lines
11 KiB
YAML

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