340 lines
7.2 KiB
YAML
340 lines
7.2 KiB
YAML
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:
|
|
$ref: '#/components/requestBodies/login'
|
|
responses:
|
|
200:
|
|
$ref: '#/components/responses/userResponse'
|
|
400:
|
|
$ref: '#/components/responses/errorResponse'
|
|
/user/register:
|
|
post:
|
|
security: []
|
|
requestBody:
|
|
$ref: '#/components/requestBodies/register'
|
|
responses:
|
|
200:
|
|
$ref: '#/components/responses/userResponse'
|
|
400:
|
|
$ref: '#/components/responses/errorResponse'
|
|
/user/logout:
|
|
post:
|
|
security: []
|
|
responses:
|
|
204:
|
|
description: "success logout"
|
|
400:
|
|
$ref: '#/components/responses/errorResponse'
|
|
|
|
# Game routes
|
|
/games:
|
|
get:
|
|
security: []
|
|
responses:
|
|
200:
|
|
$ref: '#/components/responses/gameListResponse'
|
|
post:
|
|
operationId: createGame
|
|
security:
|
|
- cookieAuth: [creator, admin]
|
|
requestBody:
|
|
$ref: "#/components/requestBodies/gameEditRequest"
|
|
responses:
|
|
200:
|
|
$ref: "#/components/responses/gameResponse"
|
|
/engine/{uid}:
|
|
get:
|
|
operationId: gameEngine
|
|
parameters:
|
|
- name: uid
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: integer
|
|
responses:
|
|
200:
|
|
$ref: '#/components/responses/taskResponse'
|
|
/engine/{uid}/code:
|
|
post:
|
|
operationId: enterCode
|
|
parameters:
|
|
- name: uid
|
|
in: path
|
|
required: true
|
|
schema:
|
|
type: integer
|
|
requestBody:
|
|
$ref: "#/components/requestBodies/enterCodeRequest"
|
|
responses:
|
|
200:
|
|
$ref: '#/components/responses/taskResponse'
|
|
|
|
components:
|
|
schemas:
|
|
userView:
|
|
type: object
|
|
properties:
|
|
id:
|
|
type: integer
|
|
username:
|
|
type: string
|
|
required: [ id, username ]
|
|
gameView:
|
|
type: object
|
|
properties:
|
|
id:
|
|
type: integer
|
|
title:
|
|
type: string
|
|
description:
|
|
type: string
|
|
type:
|
|
$ref: "#/components/schemas/gameType"
|
|
required:
|
|
- id
|
|
- title
|
|
- description
|
|
- type
|
|
taskView:
|
|
type: object
|
|
properties:
|
|
title:
|
|
type: string
|
|
text:
|
|
type: string
|
|
codes:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/codeView'
|
|
entered:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/codeView'
|
|
solutions:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/solutionView'
|
|
required:
|
|
- title
|
|
- text
|
|
- codes
|
|
- entered
|
|
- solutions
|
|
codeView:
|
|
type: object
|
|
properties:
|
|
description:
|
|
type: string
|
|
code:
|
|
type: string
|
|
required:
|
|
- description
|
|
solutionView:
|
|
type: object
|
|
properties:
|
|
text:
|
|
type: string
|
|
after:
|
|
type: integer
|
|
required:
|
|
- after
|
|
gameEdit:
|
|
type: object
|
|
properties:
|
|
title:
|
|
type: string
|
|
description:
|
|
type: string
|
|
type:
|
|
$ref: "#/components/schemas/gameType"
|
|
tasks:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/taskEdit"
|
|
points:
|
|
type: integer
|
|
required:
|
|
- title
|
|
- description
|
|
- type
|
|
- tasks
|
|
- points
|
|
taskEdit:
|
|
type: object
|
|
properties:
|
|
title:
|
|
type: string
|
|
text:
|
|
type: string
|
|
codes:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/codeEdit'
|
|
solutions:
|
|
type: array
|
|
items:
|
|
$ref: '#/components/schemas/solutionEdit'
|
|
required:
|
|
- title
|
|
- text
|
|
- codes
|
|
- solutions
|
|
codeEdit:
|
|
type: object
|
|
properties:
|
|
description:
|
|
type: string
|
|
code:
|
|
type: string
|
|
required:
|
|
- description
|
|
- code
|
|
solutionEdit:
|
|
type: object
|
|
properties:
|
|
text:
|
|
type: string
|
|
after:
|
|
type: integer
|
|
required:
|
|
- after
|
|
- text
|
|
gameType:
|
|
type: string
|
|
enum:
|
|
- virtual
|
|
- city
|
|
requestBodies:
|
|
login:
|
|
required: true
|
|
content:
|
|
'application/json':
|
|
schema:
|
|
type: object
|
|
properties:
|
|
email:
|
|
type: string
|
|
password:
|
|
type: string
|
|
required: [ email, password ]
|
|
register:
|
|
required: true
|
|
content:
|
|
'application/json':
|
|
schema:
|
|
type: object
|
|
properties:
|
|
username:
|
|
type: string
|
|
email:
|
|
type: string
|
|
password:
|
|
type: string
|
|
password2:
|
|
type: string
|
|
required: [ username, email, password, password2 ]
|
|
gameEditRequest:
|
|
required: true
|
|
content:
|
|
'application/json':
|
|
schema:
|
|
$ref: '#/components/schemas/gameEdit'
|
|
enterCodeRequest:
|
|
required: true
|
|
content:
|
|
'application/json':
|
|
schema:
|
|
type: object
|
|
properties:
|
|
code:
|
|
type: string
|
|
required:
|
|
- code
|
|
responses:
|
|
userResponse:
|
|
description: ''
|
|
content:
|
|
'application/json':
|
|
schema:
|
|
type: object
|
|
properties:
|
|
id:
|
|
type: integer
|
|
username:
|
|
type: string
|
|
email:
|
|
type: string
|
|
experience:
|
|
type: integer
|
|
level:
|
|
type: integer
|
|
games:
|
|
type: array
|
|
items:
|
|
$ref: "#/components/schemas/gameView"
|
|
required:
|
|
- id
|
|
- username
|
|
- email
|
|
- experience
|
|
- level
|
|
- games
|
|
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"
|
|
taskResponse:
|
|
description: ''
|
|
content:
|
|
'application/json':
|
|
schema:
|
|
$ref: "#/components/schemas/taskView"
|
|
securitySchemes:
|
|
cookieAuth:
|
|
type: apiKey
|
|
in: cookie
|
|
name: session
|
|
|
|
security:
|
|
- cookieAuth: []
|